小程序云开发 遍历数组更新里面的元素
2020-06-06 本文已影响0人
愤怒的哪吒
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)
}
}