📜  mongodb 批量更新 - Javascript 代码示例

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

代码示例2
Character.bulkWrite([
  {
    updateMany: {
      filter: { name: 'Eddard Stark' },
      // If you were using the MongoDB driver directly, you'd need to do
      // `update: { $set: { title: ... } }` but mongoose adds $set for
      // you.
      update: { title: 'Hand of the King' }
    }
  }
]).then(res => {
 // Prints "1 1 1"
 console.log(res.modifiedCount);
});