📜  猫鼬查找和更新道具 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:04.327000             🧑  作者: Mango

代码示例1
var query = {'username': req.user.username};
req.newData.username = req.user.username;

MyModel.findOneAndUpdate(query, req.newData, {upsert: true}, function(err, doc) {
    if (err) return res.send(500, {error: err});
    return res.send('Succesfully saved.');
});