.match,相当于where条件
.group,就是分组啦,其中_id是固定写法,不能写成其他的
.sort,相当于orderBy排序
其返回值是:res.result.list,不是:res.result.data
const db = wx.cloud.database()
const _ = db.command
const $ = _.aggregate
db.collection('v4_colorseesee').aggregate()
.match({
game: 'colorfont'
})
.group({
_id: {
openid: '$openid',
player: '$player'
},
maxLevel: $.max('$level')
})
.sort({
maxLevel: -1,
date: 1
})
.end()
.then(res => {
console.info(res)
})
网友评论