I am new to MongoDB and I have the following documents:
{
"_id":ObjectID("55b89409b7d7df8c3d201618"),
"name":"John"
},
{
"_id":ObjectID("55b14359b7d7df8c3d20161c"),
"name":"Bahubali",
"products":7,
"contact_no":8819936800
}
I need to edit the document which has the name "John"
. I need to add more fields to this document. But, when I use update
, it can update only the specific name
field and when I use save
, it replaces the existing document with new document.
Is there any other approach to add new fields to the above document without using save
. Because whenever we use save, we will require to rewrite the whole document.