Discord.js MongooseError: Callback must be a function, got [object Object]
.deleteOne()
accepts three parameters; a filter object, an options object, and a callback function. You pass an object as the third parameter ({ upsert: true }
) and that's why Mongo is complaining that a callback must be a function, got [object Object]
.
It looks like you just replaced an updateOne
or findOneAndUpdate
method with a deleteOne
and haven't checked the documentation how to use it.
I'm not sure what you're trying to delete. If it's a document with a certain userID, you can use the following:
try { await premiumSchema.deleteOne({ userID: user.id });} finally { // ...}