mongooseasynchronous/等待查找然后编辑和保存?

是否有可能做一个查找,然后保存使用asynchronous/等待承诺?

我有以下代码:

try { var accounts = await Account.find() .where("username").in(["tkrones@gmail.com"]) .exec(); accounts.password = 'asdf'; accounts.save(); } catch (error) { handleError(res, error.message); } 

我得到以下错误:

 ERROR: accounts.save is not a function 

这是我正在寻找的:

 try { var accounts = await Account.findOneAndUpdate( {"username" : "helllo@hello.com"}, {$set: {"password" : "aaaa"}}, {new : true} ); res.status(200).json(accounts); } catch (error) { handleError(res, error.message); } 

或者(感谢@JohnnyHKfindvs findOne小费!):

 try { var accounts = await Account.findOne() .where("username").in(["hello@hello.com"]) .exec(); accounts.password = 'asdf'; accounts.save(); res.status(200).json(accounts); } catch (error) { handleError(res, error.message); }