【发布时间】:2014-12-30 05:59:15
【问题描述】:
我使用了 MongoDB,我有模型 retailer 有很多 stores,我想退货至少有一家商店的零售商。
我发现了这个问题:How can I find records by “count” of association using rails and mongoid?
但公认的答案是:
scope :with_at_least_n_stores, -> { where('stores_count >= 1') }
取决于零售商模型中的stores_count 字段,但我没有此字段。
任何解决方案都可以找到至少拥有一家使用范围而不添加字段为stores_count 的商店的零售商?
【问题讨论】:
标签: ruby-on-rails mongodb scope has-many