0
我有以下型号:Mongoid,复杂查询,类似的has_many东西:通过
class Company
# ...
has_many :invoices
end
class Invoice
# ...
belongs_to :company
has_many :items
field :type, String
scope :expense, where(type: 'expense')
scope :income, where(type: 'income')
end
class Item
# ...
belongs_to :invoice
end
的问题是如何获取所有income
项目对于给定的公司?
类似的东西来company.items.expense