微信小程序更新云数据库时发生VM1815 WAService.js:1 thirdScriptError错误

更新云数据库时发生VM1815 WAService.js:1 thirdScriptError错误

代码:

update(id,complete){
        var db = wx.cloud.database().collection('info')
        db.where({
            _id:id,
        })
        .update({
            data:{
                complete:complete,
            }
        })
        .then(res=>{
            console.log('更新complete成功',res)
        })
        .catch(res=>{
            console.log('更新complete失败',res)
        })
    }

运行结果

img

集合update是于wx-server-sdk的方法,需要导入wx-server-sdk
具体参考下面的

客户端可以用document的update方法,改下面这样


        update(id, complete) {
            var db = wx.cloud.database().collection('info')
            db.doc(id)//改doc获取记录而不是where,
                .update({
                    data: {
                        complete: complete,
                    }
                })
                .then(res => {
                    console.log('更新complete成功', res)
                })
                .catch(res => {
                    console.log('更新complete失败', res)
                });
        }

img

你打印 一下 db看看 where 下面 有没有 update 。
你这个报错是 db.where..update不是一个函数