below is my collection in Mongo dB
[{
"_id": "5d1c3f9384d8c520c0d647d0",
"userName": "test@outlooks.com",
"password": "$2b$10$TM8MLk1VIl1PHaBNBG.EK.Maj.UjdI1r1M.s4THSM5wYkKnWKU82a",
"firstName": null,
"lastName": null,
"cards": [{
"cardName": "card-1",
"stage1": [],
"stage2": [],
"lastExamDate": null,
"createdDate": "2019-07-03T06:55:45.890Z"
}, {
"cardName": "card-2",
"stage1": [],
"stage2": [],
"lastExamDate": null,
"createdDate": "2019-07-03T07:14:32.278Z"
}]
},
{
"_id": "384d8f9384d8c520c0d333m9",
"userName": "sample@gmail.com",
"password": "$kKn10$TM8MLk1VIl1PHaBNBG.EK.Maj.UjdI1r1M.s4THSM5wYkKnWKUkKn",
"firstName": user1,
"lastName": last1,
"cards": [{
"cardName": "English",
"stage1": [],
"stage2": [],
"lastExamDate": null,
"createdDate": "2019-07-03T06:55:45.890Z"
}, {
"cardName": "Spanish",
"stage1": [],
"stage2": [],
"lastExamDate": null,
"createdDate": "2019-07-03T07:14:32.278Z"
}]
}
]
here is what Im trying to do in mongo dB with Node.js
User want to update the cardName from card-1 to Germany.
as you see cardName is an object inside an array.
1- I have to find the _id
2- then I have to find the cardName he want to update.
3- update the cardName with the new one
I couldn't figure it out how to do that.