Reputation: 328
I know I can find entries in mongodb that match a certain array of values natively via this command:
db.vendors.find({"somearray.property": { $in: ["value1","value2"]}})
But how can I do this with the ruby driver 'mongo' gem?
col.find("somearray.property" => ["value1","value2"])
Regards
Upvotes: 2
Views: 1047
Reputation: 19238
You can do it like this:
col.find("somearray.property" => { '$in' => ["value1","value2"] })
Upvotes: 2
Reputation: 17631
Not sure to understand what you mean by the "ruby driver" but if you are using mongoid (which I recommend when dealing with mongodb) you can do
col.where(:'somearray.property'.in => ["val1", "val2"])
More informations here
Upvotes: 1