node.js - 使用sequelize 更新字段值怎么自动+1

【字号: 日期:2022-09-21浏览:35作者:雯心

问题描述

使用sequelize 更新字段值怎么自动+1比如我想更新文章的浏览人数,怎么自动更新浏览人数+1,而不用先获得当前浏览人数再去+1呢?

db.nices.update({lookcount:parseInt(req.query.lookcount)+1},{where:{id:id}}).then(function (resule) { console.log(resule); if(resule>0){`请输入代码`res.json({ code:200, msg:'成功', object:''}) }})

问题解答

回答1:

之前纠结过…然后直接上sequelize.literal了…

相关文章: