Mongo and / or in one request

I am trying to find the best way to request mangoes. I am using Mongoid and the latest version of mongo

What I want to do is request

user_id => [array of identifiers] and user_type => "some_type" OR user_id => [array of identifiers] and user_type => "some_type"

How can I do this in Mongo / Mongoid?

+4
source share
1 answer

In mongo shell, it will be something like

db.yourcollection.find({$or: [ {user_id: {$in: [array_of_ids]}, user_type: "some_type"}, {user_id: {$in: [array_of_ids2]}, user_type: "some_type2"} ]}); 
+8
source

All Articles