label : {
field1 : { .....},
field2 : {.....}
}
db.collection.update({_id:"objectId"},{$set : label})
I have a single collection with multiple fileds and I want to update field1
without removeing field2
, is this possible?
For example
{
"_id" : ObjectId("56fa03....."),
"categories" : {
"category_name" : {
"en" : "Category Name",
"dk" : "Category Name DK"
},
"color" : { "en" : "Color", "dk" : "Color DK" }
}
}
Here I want to update category_name
without removeing color. How do I update a single field1 in a record?