关于增加字段值的疑惑 - Update 无法更新字段?
发布于 5 年前 作者 xiulan63 14097 次浏览 来自 问答

我想实现 点击文章后,在字段 view 上加 1, 但是 update 不成功 :

    db.collection('soda').where({
        _id: options.sodaid
    }).get({
      success: function(res) {
      //更新浏览数量
      if (res.data.length!=0) {
        db.collection('soda').where({
          _id: res.data[0]['_id']
        }).update({
          data: {
            view: res.data[0]['view'] + 1 ,//浏览量
          }
        })
      }
      // 输出
      that.setData({
        soda: res.data[0]
      })
     }
    });
回到顶部