如何在云函数中实现批量插入数据?
.add({ data: [ { _id: 'apple-1' , name: 'apple' , category: 'fruit' , price: 10, }, { _id: 'orange-1' , name: 'orange' , category: 'fruit' , price: 15, }, { _id: 'watermelon-1' , name: 'watermelon' , category: 'fruit' , price: 20, }, { _id: 'yaourt-1' , name: 'yaourt' , category: 'dairy' , price: 8, }, { _id: 'milk-1' , name: 'milk' , category: 'dairy' , price: 12, }, { _id: 'chocolate-1' , name: 'Lindt chocolate' , category: 'chocolate' , price: 16, }, ] }) |
我在云开发后台操作这段批量插入的代码是可以正常执行的,
但写在云函数里面却报了以下错误
parameter.data should be object instead of array
请问云函数里面可以做批量插入吗,要怎么写才对呢?