Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoose bulk update

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);
});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mongoose #bulk #update
ADD COMMENT
Topic
Name
6+1 =