文件必须是有效的JavaScript物件

时间:2018-10-18 09:29:00

标签: node.js mongodb

我有这个脚本:

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

你知道我为什么要这么做吗?

谢谢!

0 个答案:

没有答案