[error] 函数执行失败(耗时 5656ms) Error: collection.add:fail -501001 resource system error. 413 Payload Too Large | [http://tcb-api.tencentcloudapi.com/admin?&eventId=17c071f7a71_3&seqId=17c071f7a71_3]
at toSDKError (/xxx/cloudfunctions/ordercollect/node_modules/wx-server-sdk/index.js:8089:19)
at Object.returnAsFinalCloudSDKError (/xxx/cloudfunctions/ordercollect/node_modules/wx-server-sdk/index.js:8060:12)
at /xxx/cloudfunctions/ordercollect/node_modules/wx-server-sdk/index.js:1225:32
at processTicksAndRejections (internal/process/task_queues.js:97:5)
意思是一次请求数据量太大吗?之前用add提交20000+条数据,没报这个错啊。是新加了限制吗?
如果数据量太大怎么add呢?
代码:
console.log('读取数据[记录数=' + recordsLength + '][耗时=' + readMS + '秒]')
// return
await db.collection('xxx').add({
data: data
}).then(res => {
if (res.errMsg == 'collection.add:ok') {
let after = new Date()
let costMS = (after.getTime() - read.getTime()) / 1000
console.log('统计成功: [统计月份=' + lastMonthYm + '][记录生成时间=' + nowStr + '][生成记录数量=' + recordsLength + '][耗时=' + costMS + '秒]')
} else {
console.log('统计失败:', res)
}
})
问题已经用循环变相解决了。有没有更优雅的方案?
大小不是按数量的,一条一个属性和一条100个属性,不一样的,怎么循环的?一次一条?