Reputation: 1743
We have a mongodb document with the following structure: One of the document's fields is a map, and each map entry has several fields of it's own.
We want a way to update the value of one field inside a specific map entry using mogodb update query.
To clarify things, if we have the document as bellow, we want to update "callBackUrl" for entry 1 in the map "urlSettings" to "yadayada.com". Is that possible at all?
SystemSettings : {
urlSettings : {
1 : {
callBackUrl : "blabla.com",
(more fields...)
},
2 : {
...
},
...
},
...
}
Upvotes: 0
Views: 1359
Reputation: 2029
check the below query :
db.collection.update(
{"SystemSettings.urlSettings.1.callBackUrl" : "blabla.com"},
{"$set":{"SystemSettings.urlSettings.1.callBackUrl" : "yadayada.com"}}
);
Upvotes: 2