search

Home  >  Q&A  >  body text

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

使用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) {

            console.log(resule);

            if(resule>0){`请输入代码`

                res.json({

                    code:200,

                    msg:"成功",

                    object:""

                })

            }

        })</code>

PHPzPHPz2874 days ago607

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-17 16:06:21

    I was struggling before...then I went directly to sequelize.literal...

    reply
    0
  • Cancelreply