和楼主一样的问题,这是怎么回事呢,直接用的官方给的例子都不行
如何在云函数中实现批量插入数据?[代码]db.collection([代码][代码]'test'[代码][代码])[代码] [代码] [代码][代码].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 请问云函数里面可以做批量插入吗,要怎么写才对呢?
2019-12-03