我有3个相关模型:
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
我想对具有某些条件的交易进行查询:
x < volume < y
and
a < deal_date < b
and
( buyer.name like key_word OR seller.name like key_word )
如何使用 Datamapper 在两个 LIKE 之间创建 OR 条件?