[英]nodejs put method to update data
我正在尝试在 nodejs(express) 中创建一个 put 方法,以便我可以移动到前端并更新我的数据,但是当我在 postman 上的 go 并尝试它时,我的终端出现错误。
我的错误: AssertionError [ERR_ASSERTION]: Missing where attribute in the options parameter
app.put('/zoom/:id', function(req, res) {
return data.update({
subject: req.body.subject,
MEETINGID: req.body.MEETINGID,
Password: req.body.Password
}).then(function (data) {
if (data) {
res.send(data)
} else {
res.status(400).send('Error')
}
})
})
您正在使用更新 function 更新数据表,但要使用更新 function 您应该在更新 function 中使用 where 参数,以便可以分析要更新的数据。 例如:-
app.put('/zoom/:id', function(req, res) {
return data.update({
subject: req.body.subject,
MEETINGID: req.body.MEETINGID,
Password: req.body.Password
}, {
where : {
id: id /*like this*/ }}).then(function (data) {
if (data) {
res.send(data)
} else {
res.status(400).send('Error')
}
})
})
希望这可以帮助。 请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.