云函数代码如下:
const cloud = require(‘wx-server-sdk’)
cloud.init({
env: ‘egyptmanagement-8a2de’
})
const db = cloud.database()
const _ = db.command
const $ = db.command.aggregate
// 云函数入口函数
exports.main = async(event, context) => {
//var cmd = event.cmd;
console.log(event);
db.collection(‘eat’).aggregate().group({
_id: {
address: ‘$address’,
date: ‘$date’,
type: ‘$type’
},
tsum: $.sum(’$number’)
}).end().then(res => {
console.log(“结果:”,res)
return res
})
return null
}
eat collection里面有5条数据.
number是整形,非字符串
调用查看日志成功, 但是确始终没有数据返回,