Answers for "save or update mongoose"

2

mongoose save or update

// This will create another document if it doesn't exist
findByIdAndUpdate(_id, { something: 'updated' }, { upsert: true });
Posted by: Guest on October-11-2020
-1

save or update mongoose

// SAVE NEW OR UPDATE EXISTING COLLECTION
AnnoucementTagsModel.findOneAndUpdate({_id: announcementId}, newAnnoucementTags, {upsert: true}, function (err, doc) {
	if (error) throw new Error(error);
	console.log("succesfully saved");
});
Posted by: Guest on February-21-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language