// 云函数入口文件 const cloud = require('wx-server-sdk'); const TcbRouter = require('tcb-router'); const getParams = (ctx) => { let params = ctx._req.event; delete params.$url; return params; }; const success = (data) => { return { status: 200, data, }; }; cloud.init({ env: 'release-4gh0j0n9669b023d', }); let db = cloud.database({ env: 'release-4gh0j0n9669b023d', }); const _ = db.command; // 云函数入口函数 exports.main = async (event, context) => { const app = new TcbRouter({ event, context, }); app.router('get_audit_list', getAuditList); return app.serve(); }; async function getAuditList(ctx, next) { const log = cloud.logger(); let params = getParams(ctx); let { page_no, page_size } = params; let skipCount = (page_no - 1) * page_size; let limitCount = page_size; let searchTask = await db .collection('uploadHistory') .aggregate() .lookup({ from: 'userInfo', localField: 'openid', foreignField: 'openid', as: 'userInfo', }) .match({ userInfo: { contact: 1, }, status: 0, }) .sort({ upload_time: -1, }) .skip(skipCount) .limit(limitCount) .end(); ctx.body = success(searchTask.list); }
云函数崩了?AppID:wx2805712f06257587 函数执行失败(耗时 5216ms) Error: collection.aggregate:fail -501001 resource system error. [FailedOperation.Timeout] Execution request timeout, Please check optimize your request(such as index), but if the problem persists, contact us.[图片]
2021-11-19