之前从数据库中取出20条数据,数据格式例如:
…
{name: ‘张三’, ‘phone’: ‘110’, prize: ‘0’}
…
修改了其中10条数据的prize更新为不同的数字
{name: ‘张三’, ‘phone’: ‘110’, prize: ‘1’},{name: ‘李四’, ‘phone’: ‘110’, prize: ‘2’},{name: ‘王二麻子’, ‘phone’: ‘110’, prize: ‘3’},{name: ‘赵四’, ‘phone’: ‘110’, prize: ‘4’},{name: ‘钱三’, ‘phone’: ‘110’, prize: ‘5’},{name: ‘张三1’, ‘phone’: ‘110’, prize: ‘6’},{name: ‘李四1’, ‘phone’: ‘110’, prize: ‘7’},{name: ‘王二麻子1’, ‘phone’: ‘110’, prize: ‘8’},{name: ‘赵四1’, ‘phone’: ‘110’, prize: ‘9’},{name: ‘钱三1’, ‘phone’: ‘110’, prize: ‘10’},
我现在是for循环写的,
arr.forEach((ele) => {
.update({ data: { prize: ele.prize }
|
可以一次性更新多条数据的写法吗?