Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

how to add a new propety into all documents in mongodb

db.users.update({}, { "$set" : { "age": 30 }}, false,true)
// users: collection name, age: new property
//false it's upsert argument, it tells mongo to not insert a new document when no match is found
// true it's multi argument, it tells mongo to update multiple documents that meet the query criteria
 
PREVIOUS NEXT
Tagged: #add #propety #documents #mongodb
ADD COMMENT
Topic
Name
7+6 =