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