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.
我正在尝试找出查询 mongo 的最佳方法。我正在使用 Mongoid 和最新的 mongo 版本
我想要做的是这样的查询
user_id => [id 数组] 和 user_type => "some_type" 或 user_id => [id 数组] 和 user_type => "some_type"
我怎样才能在 Mongo/Mongoid 中做到这一点?
在 mongo shell 中,它会是这样的,
db.yourcollection.find({$or: [ {user_id: {$in: [array_of_ids]}, user_type: "some_type"}, {user_id: {$in: [array_of_ids2]}, user_type: "some_type2"} ]});