云函数排行榜
计算当日打卡排行榜
云函数
function getClockInRankingList() {
return db.collection('ClockIn').aggregate()
.match({
flockId: event.flockId,
date: event.date
})
.group({
_id: '$touser',
list: $.push({
clock: '$clock',
})
})
.project({
total: $.size('$list')
}).sort({
total: -1,
})
.skip(event.rankingLength)
.limit(event.limit)
.lookup({
from: 'User',
localField: '_id',
foreignField: '_id',
as: 'userInfo',
}).end()
}