0

我正在尝试删除所有嵌套文档,而不仅仅是一个。

这是代码:

        //find and remove all of the embedded workorder units
    db.workorders.find({units: { $ne: null } }, function(err, wos) {

      console.log(wos);
      console.log("removing the embedded workorder units");
      _.each(wos, function(wo) {

        wo.units.remove();
      });

      setTimeout(function() { next() }, 2000);

    });
4

1 回答 1

2

我想到了:

        //find and remove all of the embedded workorder units
    db.workorders.update({}, { $set: { units: [] } }, { multi: true }, function(err) {

      console.log("removing the embedded workorder units");

      next();

    });
于 2013-10-19T03:03:42.643 回答