I have few doubts about array operations on sub-documents,
How to append new object with existing array,
How to delete the sub-documents array at existing object.
How to add new field at all the sub-documents based on the conditions
Ex: This is our document
{
“iam”: “QW230”,
“fav_apps”: [
{
“app_id”: “9b94d625-e54e-4356-8728-9f598ca6e2f5”,
“status”:1
}
]
}
- I need to insert new favourite apps
“fav_apps”: [
{
“app_id”: “9b94d625-e54e-4356-8728-9f598ca6e2f5”,
“status”:1
},
{
“app_id”: “9b94d625-e54e-4356-8728-9f598ca6e2f5”,
“status”:1
}
]
2. I need to deleted sub-document like app_id as 9b94d625-e54e-4356-8728-9f598ca6e2f5,
3. How to add new field on all the sub-documents with existing values based, ex: if sub-document status key is 1 then add new key for force_update with 0, otherwise to add force_update as 1
“fav_apps”: [
{
“app_id”: “9b94d625-e54e-4356-8728-9f598ca6e2f5”,
“status”:1,
“force_update”:0
},
{
“app_id”: “9b94d625-e54e-4356-8728-9f598ca6e2f5”,
“status”:0,
“force_update”:1
}
]
Thanks,