为什么与GraphQL一起使用时出现mongoose保存raise错误?
我添加了这个GraphQL解析器函数为什么与GraphQL一起使用时出现mongoose保存raise错误?,mongoose,graphql,Mongoose,Graphql,我添加了这个GraphQL解析器函数 switchEventSellingStarted: async(_, {name, sellingStarted}) => { const e1 = Event.findOne({name: name}) if (!e1) { throw new Error(`Couldn't find post with id ${name}`); } e1.sellingStarted = sell
switchEventSellingStarted: async(_, {name, sellingStarted}) => {
const e1 = Event.findOne({name: name})
if (!e1) {
throw new Error(`Couldn't find post with id ${name}`);
}
e1.sellingStarted = sellingStarted;
await e1.save();
return e1;
}
当执行解析器时,出现了这个错误,为什么
{
"errors": [
{
"message": "e1.save is not a function",
您错过了
事件前的等待。findOne
。没有它,e1
就是一个承诺,在承诺对象上没有名为save
的方法