Mongoose async/await find然后编辑并保存?

Dev*_*v01 8 asynchronous mongoose mongodb node.js

是否可以使用async/await promise进行查找然后保存?

我有以下代码:

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

我收到以下错误:

ERROR: accounts.save is not a function
Run Code Online (Sandbox Code Playgroud)

Dev*_*v01 10

这就是我要找的东西:

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);
}
Run Code Online (Sandbox Code Playgroud)

或者(感谢@JohnnyHK查找与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);
}
Run Code Online (Sandbox Code Playgroud)