云开发更新数组元素,位置是变量怎么处理?
发布于 6 年前 作者 gang48 4741 次浏览 来自 官方Issues
db.collection('todos').where({
  'root.objects.1.numbers.2': 70}).get()

这里的数字传变量进去会被认为是元素,要怎么处理?

1 回复

加个中括号

var x = 1,y = 2

var key = ‘root.objects.’ + x + ‘.numbers.’ + y

db.collection(‘xxx’).doc(‘sss’)

.update({

    data: {

        [key]: 70

    }

})

回到顶部