云函数代码如下所示:
let order_list = await db.collection('ops_order').aggregate().sort({
update_time: -1
}).match({
card_id: _.in(id_array),
status: status
}).project({
user_openid: 0,
update_time_show: $.dateToString({
date: '$update_time',
format: '%Y-%m-%d %H:%M:%S',
timezone: 'Asia/Shanghai'
})
}).limit(limit_num).skip(skip_num).end();
报错信息如下所示:
{
"errCode":1,
"errMsg":"user code exception caught",
"stackTrace":"Error: collection.aggregate:fail -502001 database request fail. [FailedOperation] (Location40182) Bad projection specification, cannot include fields or add computed fields during an exclusion projection: { user_openid: 0, update_time_show: { $dateToString: { date: \"$update_time\", format: \"%Y-%m-%d %H:%M:%S\", timezone: \"Asia/Shanghai\" } } }\n at Object.toSDKError (/var/user/node_modules/wx-server-sdk/index.js:8089:19)\n at Object.checkError (/var/user/node_modules/wx-server-sdk/index.js:1422:23)\n at /var/user/node_modules/wx-server-sdk/index.js:1161:33\n at processTicksAndRejections (internal/process/task_queues.js:97:5)"
}
想请教大佬们,该如何修改?
发现是project中下面一行的问题,将其删除或者值改为1即可。
user_openid: 0,