Skip to content

Commit

Permalink
mongoose: not save undefined values as null when editing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico105 committed Jul 5, 2021
1 parent 4330bd7 commit aba4c64
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/custom-databases/mongoose.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
// This function is called when a giveaway needs to be edited in the database.
async editGiveaway(messageID, giveawayData) {
// Find by messageID and update it
await giveawayModel.findOneAndUpdate({ messageID: messageID }, giveawayData).exec();
await giveawayModel.findOneAndUpdate({ messageID: messageID }, giveawayData, { omitUndefined: true }).exec();
// Don't forget to return something!
return true;
}
Expand Down

0 comments on commit aba4c64

Please sign in to comment.