云数据库插入,总是失败,各种可能性都试了,错误提示是unknow也看不懂了?
发布于 7 年前 作者 whan 11831 次浏览 来自 问答

已经解决:本地调试各种错误,云端测试直接成功了

index.js:52 CloudSDKError: errCode: -1 unknown error | errMsg: collection.add:fail Error: 

          400 Bad Request

        ; at collection.add api; 

    at returnAsCloudSDKError (C:\Users\Administrator\WeChatProjects\miniprogram-3\cloudfunctions\obj\node_modules\wx-server-sdk\index.js:6086:16)

    at Object.returnAsFinalCloudSDKError (C:\Users\Administrator\WeChatProjects\miniprogram-3\cloudfunctions\obj\node_modules\wx-server-sdk\index.js:6100:15)

    at Promise (C:\Users\Administrator\WeChatProjects\miniprogram-3\cloudfunctions\obj\node_modules\wx-server-sdk\index.js:1198:32)

    at processTicksAndRejections (internal/process/task_queues.js:86:5)

代码如下

let db_temp = db.collection("objects")

for(let i in result.data){

let data_record = {

name: result.data[i].field_2,

abstract: result.data[i].field_4,

sex: result.data[i].field_5,

price: result.data[i].field_3,

players: result.data[i].field_1,

thumbnails: result.data[i].field_6,

serial_number: result.data[i].serial_number

}

console.log(data_record)

try{

return await db_temp.add({

data: data_record

})

} catch(e){

console.error(e)

}

}

3 回复

需要先看console.log(data_record)的结果

现在是否正常?

db哪来的,请贴完整的云函数代码

回到顶部