Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何在 Mongoid 中使用AND条件进行查询?
您可以链接where语句或在调用中包含多个条件where。
where
Model.where(condition_a: :a, condition_b: :b).all
或者
Model.where(condition_a: :a).where(condition_b: :b).all
此外,您可以使用.and(other_thing:'value')
.and(other_thing:'value')
例如,Model.where(awesome:true).and(other_thing:true)
Model.where(awesome:true).and(other_thing:true)