i have a structure like this
{
"name":"xxxxxx",
"list":[
{
"listname":"XXXXX1",
"card":[
{
"title":"xxxxxx",
"descip":"xxxxxxxxxx",
"id":"1213"
},
{
"title":"xxxxxx",
"descip":"xxxxxxxxxx",
"id":"1214"
}
]
},
{
"listname":"xxxxxx2",
"card":[
{
"title":"xxxxxx",
"descip":"xxxxxxxxxx",
"id":"1345",
},
{
"title":"xxxxxx",
"descip":"xxxxxxxxxx",
"id":"1346",
}
]
}
]
}
here listname is unique in list array and then id is unique in card array.
i want to insert extra two key value pair into specific document of card array . example now i want to add extra key value into id number 1213
the out put should look like this
"card":[
{
"title":"xxxxxx",
"descip":"xxxxxxxxxx",
"id":"1213",
"name":"XXXXxx",
"age":"xxxx"
},
{
"title":"xxxxxx",
"descip":"xxxxxxxxxx",
"id":"1214",
}
]
how to update?
Try mongodb positional operator.
Your query will be like list.$.id = 123
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.