So I’ve been working to finish my Welcomer bot on Discord, but I couldn’t, because I can’t find a way how I can remove a String from an object!
So I have my welcome object and 3 strings inside of the welcome object. How can I delete one of the strings with using JavaScript & mongoose? Some people told me to use $unset but when I try to use it, it deletes the welcome object with my 2 strings
The below does 3 things,keeps the channel as it was,updated the message,and removes the guilid.
Its update pipeline so you need mongoDB >=4.2.With the old update way its even simpler from this
code but pipelines updates are so powerful,so i use those.
You care for the pipeline,this part
[{"$project":{"welcome":{"channel":"$welcome.channel","message":"Hello updated!"}}}]