Das habe ich gesucht:
try {
var accounts = await Account.findOneAndUpdate(
{"username" : "[email protected]"},
{$set: {"password" : "aaaa"}},
{new : true}
);
res.status(200).json(accounts);
} catch (error) {
handleError(res, error.message);
}
oder (danke @JohnnyHK für den find vs findOne-Tipp!):
try {
var accounts = await Account.findOne()
.where("username").in(["[email protected]"])
.exec();
accounts.password = 'asdf';
accounts.save();
res.status(200).json(accounts);
} catch (error) {
handleError(res, error.message);
}