save or update mongoose

JavaScript
// This will create another document if it doesn't exist
findByIdAndUpdate(_id, { something: 'updated' }, { upsert: true });// 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");
});
Source

Also in JavaScript: