nodejs mongodb the update operation document must contain atomic operators code example

Example 1: the update operation document must contain atomic operators mongodb

db.getCollection('users')
  .updateMany(
  {'name':{'$exists':1}}, //Query
  {'$set': { //Values to update
    'name':'New Name'
  	}
  }
)

Example 2: the update operation document must contain atomic operators mongodb

db.c20160712.updateOne(
    { "Attribute" : "good" }, 
    { $set: {"Type" : "DVD", "Title" : "Matrix, The", "Released" : 1999, "Genre" : "Action" } },
    { upsert: true }
);

Tags:

Misc Example