I have a collection (favorites) with documents that look like this:
{
"_id" : 907,
"pictures" : [
{
"id" : 107,
"url" : "http://url1",
"title" : "some title"
},
{
"id" : 111,
"url" : "http://url2",
"title" : "some other title"
}
]
}
It's fairly easy to get just the urls using pictures.url.
But how do I update the url for all users that saved the picture with an id=111 as their favorite?
I found an work-around using:
107:['id':107,'url':'http://url1','title':'some title']
...and then using find() with pictures.107.id => 107, but that looks silly to me.
Is there a better way to achieve this?
107or111? Or both?pictures.urlinfind(). with the workaround I am forced to get from mongo all fields inpictures