小程序云开发 遍历数组更新里面的元素

json数据结构


遍历修改属性

附上代码

const usersTable = db.collection("getImages")

// 云函数入口函数

exports.main = async(event,context)=> {

   try {

await usersTable.where({

'_id':event._id,

          'item.imgId':event.imgId

}).update({

        data: {

          'item.$.name':event.imgName

          }

})

} catch(e){

console.error(e)

    }

}


你可能感兴趣的:(小程序云开发 遍历数组更新里面的元素)