I have this schema for my user
supposedly I want to find the user _id first then insert a new object inside the new notification array. and it should look like this
How can I achieve this, assuming that the notification property is non existent in the user document first, i need to check if notification property is present else add the notification property and push the new object
this code is not working for me
Use $addToSet operator to achieve that
If that doesn’t work try to add the default value too, and then that must work
If you have better answer, please add a comment about this, thank you!