Removing a String from an Object

Hello everyone,

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

Any help would be appreciated :heart:
Screenshot_20200909_172813|690x107

Hello @Mystic_Devs : )

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!"}}}]
> use testdb
switched to db testdb
> db.testcoll.drop()
true
> db.testcoll.insert({"welcome":{"channel":"73577","message":"Hello","guildid":"75720"}});
WriteResult({ "nInserted" : 1 })
> db.testcoll.find({}).pretty();
{
	"_id" : ObjectId("5f59524e2780882cafc2417b"),
	"welcome" : {
		"channel" : "73577",
		"message" : "Hello",
		"guildid" : "75720"
	}
}
> db.testcoll.update({},[{"$project":{"welcome":{"channel":"$welcome.channel","message":"Hello updated!"}}}]);
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
> db.testcoll.find({}).pretty();
{
	"_id" : ObjectId("5f59524e2780882cafc2417b"),
	"welcome" : {
		"channel" : "73577",
		"message" : "Hello updated!"
	}
}

Hope it helps and good luck with your bot.