I have collection the structure of which is :-
Subscribed.insert({
"name": "Manager1",
"emailId": "arora.priya4172@gmail.com",
"category": "Finance",
"designation": 'Head',
"done": false,
"categorySubscribedUsers": [
{
"_id": "u4._id",
"username": "u4.profile.name",
"issuesNotToDisplay": []
},
{
"_id": "u4._id",
"username": "u4.profile.name",
"issuesNotToDisplay": []
},
{
"_id": "u4._id",
"username": "u4.profile.name",
"issuesNotToDisplay": []
}
]
});
I want to insert a field in issuesNotToDisplay field. So, for this I am using the following command but getting error:
'syntax error: missing : after property id' in browser console and 'syntax error missing token .'
In the mongodb console.
Can anyone please tell me what should be the proper command for updating a field in doubly nested array in mongodb. I have tried a lot and read book too but still clueless. Why this command is giving error?
Command is :-
db.subscribed.update(
{
"category": "Finance",
"categorySubscribedUsers": "priya"
},
{
"$addToSet": {
"categorySubscribedUsers.$.issueNotToDisplay": "25PEgZoMamLSTDdw7"
}
}
);