I have 3 related models:
class Transaction
include DataMapper::Resource
property :id, Serial
property :volume, Float
property :deal_date, Date
belongs_to :buyer
belongs_to :seller
end
class Seller
include DataMapper::Resource
property :id, Serial
property :name, String
has n, :transactions
end
class Buyer
include DataMapper::Resource
property :id, Serial
property :name, String, :length => 255, :index => true, :unique => true
has n, :transactions
end
I want make a query to tranactions with some conditions:
x < volume < y
and
a < deal_date < b
and
( buyer.name like key_word OR seller.name like key_word )
How can I make OR condition between two LIKE with Datamapper?
Simply query
Transaction, but with query-paths tobuyer.nameandseller.name.Transaction.all('buyer.name.like' => keyword) | Transaction.all('seller.name.like' => keyword)