Mongodb with rails, find by id in array

I can get the element by BSON ID from Mongodb using

db.my_collection.find({_id: ObjectId("567bc95ab62c732243123450")}) 

And it works. But how can I get an array of identifiers? something like

 db.my_collection.find({_id: [ObjectId("567bc95ab62c732243123450"])}) 

I tried different ways, as suggested on the mongodb website, but the interactive shell complained about the syntax.

EDIT:

Problem detected:

he should be

 db.my_collections.find({_id: { $in : [ObjectId("567bc95ab62c732243123450")]}}) 
+7
source share
1 answer

And in Rails:

 MyCollection.find({'_id' => { "$in" => collection_ids}}) 
+4
source

All Articles