MongooseError:回调必须是函数,GET[Object Object] [英] MongooseError: Callback must be a function, got [object Object]
本文介绍了MongooseError:回调必须是函数,GET[Object Object]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
if (reaction.emoji.name === '✅') {
if (user.id == persToProp) {
await Reply.delete()
var date = new Date();
var today = date.getDate();
await mongo().then( async (mongoose) => { //line 76
try {
await marriageListSchema.findOneAndUpdate( //line 78
{
_id: message.author.id,
},
{
partener: persToProp,
},
{
marriageDate: today,
},
{
upsert: true,
}).exec();
} finally {
mongoose.connection.close()
}
}).catch( err => {
console.log(err);
});
我收到此错误,但我不明白原因
MongooseError:回调必须是函数,已获取[Object Object] 在Function.Model.$handleCallbackError(A:DiscordBot ode_modesmongooselibmodel.js:4857:11) 在Function.Model.findOneAndUpdate(A:DiscordBot ode_modesmongooselibmodel.js:2464:19) 在A:DiscordBotCommandspropose.js:78:58 在processTicksAndRejections(内部/process/task_queue es.js:93:5) 在异步客户端。(A:DiscordBotcommandspropose.js:76:25)
推荐答案
这是语法错误。从字面上看,您传递的是对象,而不是错误所说的函数!这可能就是您想要的?
await marriageListSchema.findOneAndUpdate(
{
_id: message.author.id,
},
{
partener: persToProp,
marriageDate: today,
},
{
upsert: true,
}).exec();
您可能需要查看这些文档:
https://mongoosejs.com/docs/tutorials/findoneandupdate.html
这篇关于MongooseError:回调必须是函数,GET[Object Object]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文