Home > Q&A > body text
使用sequelize 更新字段值怎么自动+1比如我想更新文章的浏览人数,怎么自动更新浏览人数+1,而不用先获得当前浏览人数再去+1呢?
1
2
3
4
5
6
7
8
9
10
<code>db.nices.update({lookcount:parseInt(req.query.lookcount)+1},{where:{id:id}}).then(function (resule) {
<code>db.nices.update({lookcount:parseInt(req.query.lookcount)+1},{where:{id:id}}).then(
function
(resule) {
console.log(resule);
if(resule>0){`请输入代码`
if
(resule>0){`请输入代码`
res.json({
code:200,
msg:"成功",
msg:
"成功"
,
object:""
object:
""
})
}
})</code>
ringa_lee2017-04-17 16:06:21
I was struggling before...then I went directly to sequelize.literal...