📌  相关文章
📜  猫鼬模型在数组中查找所有具有 id 的文档 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:22.158000             🧑  作者: Mango

代码示例1
const ids =  [
    '4ed3ede8844f0f351100000c',
    '4ed3f117a844e0471100000d', 
    '4ed3f18132f50c491100000e',
];

// 3 Methods below:
// Using Mongoose with async function:
const records = await Model.find().where('_id').in(ids).exec();

// Or more concise:
const records = await Model.find({ '_id': { $in: ids } });

// Using Mongoose with callback:
Model.find().where('_id').in(ids).exec((err, records) => {});