我有这个脚本:
let offersToUpdate = [];
let offersToRemove = [];
while (await cursor.hasNext()) {
let offer = await cursor.next();
let product = await db.collection('products').findOne({_id: offer.product._id});
if (product == null) {
offersToRemove.push(offer._id);
} else {
offersToUpdate.push(offer._id);
}
}
await db.collection('offers').update({_id: {$in: offersToUpdate}});
await db.collection('offers').remove({_id: {$in: offersToRemove}});
执行它时出现此错误:
document must be a valid JavaScript object
你知道我为什么要这么做吗?
谢谢!