Dit is wat ik zocht:
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);
}
of (bedankt @JohnnyHK voor de tip find vs findOne!):
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);
}