mongodb with rails, find by id in array

I can fetch an element by BSON id from Mongodb with

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

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

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

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

EDIT:

Found a problem:

it should be

db.my_collections.find({_id: { $in : [ObjectId("567bc95ab62c732243123450")]}})

在Rails中:

MyCollection.find({'_id' => { "$in" => collection_ids}})
链接地址: http://www.djcxy.com/p/66256.html

上一篇: 如果iOS 5中没有包含字体,我们可以在iOS 6中使用字体吗?

下一篇: 带轨的mongodb,通过数组中的id查找