The existing array is as follows.
const idArr = ['5950b7bfe78afb0868dc6599','5950b532b3c06f0838ed47e2','5950afcc85881f07bf454232'];
//Each item in the array is used as the _id of the query. How to traverse the query?
idArr.forEach((item,index)=>{
db.details.find({_id:item}); //is that so? Or? . .
});
Mongodb found the answer in its official documents.
const idArr = ['5950b7bfe78afb0868dc6599','5950b532b3c06f0838ed47e2','5950afcc85881f07bf454232']; db.details.find({_id:{$in:idArr}); //This will do. Find out all at once.