MongoDB - Update - Interview Questions

How do you update documents in a collection?

 

MongoDB documents can be updated using the operation db.collection.update().

For example, below operation updates the title of an employee named 'John Doe' to 'Sr Manager'

>db.employees.update(
{fname:"John", lname:"Doe"},
{$set:{ title:"Sr. Manager"}}
)
 
Important Keywords to Remember

Subscribe to our Questions