How do i update a collection on mongodb?
-
Related:
How do i insert a document into a collection in mongodb?
How do i read a collection in mongodb?
How do i delete a document in a collection on mongodb?Perform update, note the use of the
$set
operator. Here we added the Comments key.> db.softwarelist.update({"Company" : "MongoDB"}, ... {$set : { Comments: []}}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
Check update.
> db.softwarelist.find() { "_id" : ObjectId("5c24e11ba7354c80abcfb1f2"), "Company" : "MongoDB", "Type" : "Document Oriented Database", "Year" : 2009, "Comments" : [ ] }
© Lightnetics 2024