首页 > 解决方案 > 猫鼬中的updateMany不会更新属性

问题描述

由于某种原因,我无法使用updateManymongoose(5.8.10) 更新文档中的属性。这是我的查询:

Booking.updateMany({ sessionId }, { "isPaid": true } );

在开头的文件中,上面sessionIdisPaid标志设置为 false。现在我想在所有这些文档中将此标志切换为 false。但是,这不会更新属性。

标签: mongodbmongoose

解决方案


因此,如果没有这样的回调,它似乎无法工作:

      Booking.updateMany({ sessionId }, { "isPaid": true }, null, (error, res) => {
        if(error) {
          console.log("Something went wrong when updating data!");
        }
      });

推荐阅读