You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
git/scr/food/cloudfunctions/quickstartFunctions/sumRecord/index.js

19 lines
394 B

const cloud = require('wx-server-sdk');
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
});
const db = cloud.database();
const $ = db.command.aggregate;
// 聚合记录云函数入口函数
exports.main = async (event, context) => {
// 返回数据库聚合结果
return db.collection('sales').aggregate()
.group({
_id: '$region',
sum: $.sum('$sales')
})
.end();
};