How to get multiple document using array of MongoDb id?

前端 未结 4 455
广开言路
广开言路 2020-12-08 18:42

I have an array of ids and I want to get all document of them at once. For that I am writing but it return 0 records.

How can I search using multiple Ids ?

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 19:01

    I believe you are missing the ObjectId. Try this:

    db.feed.find({ 
        _id: {
            $in: [ObjectId("55880c251df42d0466919268"), ObjectId("55bf528e69b70ae79be35006")]
        }
    });
    

提交回复
热议问题