const game_times = 5
// 云函数入口函数
exports.main = async (event, context) => {
const timestamp = new Date().getTime()
console.time("cost");
try{
let data ={
invite : 0,
gold : 0,
flag : 0,
online : timestamp, //导致失败字段
gameTimes : game_times,
recoveryTime : 0
}
await db.collection(record_Name).where({_id: _.exists(true)}).update({ data: data});
}catch(err){
console.timeEnd("cost");
throw err;
}
console.timeEnd("cost");
return {success: true}
}
增加这个 online 字段就耗时: 15011.938ms失败 , Error: errCode: -501001 resource system error | errMsg: collection.update:fail ESOCKETTIMEDOUT。
不要这个online 就耗时 4011ms左右 会成功!
压死骆驼的最后一根稻草,调大云函数运行时长,如果还是不能解决的话,尝试使用API吧,这个操作太大了,完全可以异步来做了