Tego szukałem:
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);
}
lub (dzięki @JohnnyHK za znalezienie vs findOne wskazówka!):
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);
}