收藏
回答

关于_inc(值) 数据库自增 这个里面的值不能用变量吗?

关于_inc(值) 数据库自增 这个里面的值不能用变量吗?

js:
 check(){
        const dc = db.command
                db.collection('ruku').where({
                goods_name:this.data.goodList,
                store:this.data.storeList
        }).get().then(res=>{
            console.log(res)
            db.collection('ruku').doc(res.data[0]._id).update({
                data:{
                    goods_num:dc.inc(this.data.count)
                },
                
            }).then(ress=>{
                console.log(ress)
            })
        })
    },

控制台:Error: errCode: -502001 database request fail | errMsg: [FailedOperation] multiple write errors: [{write errors: [{Cannot increment with non-numeric argument: {goods_num: "15325"}}]}, {<nil>}]
    at new t (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:17)
    at Function.success (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:17)
    at d (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:2)
    at Object.success (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:2)
    at r (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:26)
    at WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:26
    at b (WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:26)
    at WASubContext.js?t=wechat&s=1650450834060&v=2.14.1:26
    at WAServiceMainContext.js:11
    at VM9 asdebug.js:1(env: Windows,mp,1.05.2203251; lib: 2.14.1)
回答关注问题邀请回答
收藏

1 个回答

  • brave
    brave
    2022-04-20
    goods_num:dc.inc(parseInt(this.data.count))
    
    2022-04-20
    有用 4
    回复 2
    • 禹
      发表于移动端
      2022-04-20
      感谢大佬
      2022-04-20
      回复
    • minD
      minD
      2022-09-12回复
      大佬 API数据库  \"a\"  a怎么改能赋值
      2022-09-12
      回复
登录 后发表内容