I recommend you to split up the operations(find at first, then update, then save) Try something like this in callback of your put handler:
const updates = Object.keys(req.body)
try {
const account = await Account.findById(req.params.id)
updates.forEach((update) => account[update] = req.body[update])
await account.save()
if (!account) {
return res.status(404).send()
}
res.send(account)
} catch (e) {
res.status(400).send(e)
}
CLICK HERE to find out more related problems solutions.