db.collection('profiles') .aggregate() .group({ _id: { _id: '$zhahao', danweiname:'$weime', username:'$uname', }, count: $.sum(1) }) .sort({ count: -1, //这里对查询结果的danweiname和username 进行排序要怎么写呢? }) .end() .then(res => { // output: res.result === 3 }).catch(err => { // handle error }) 上面的排序是对count进行排序 ,想要对查询结果的_id里面的danweiname和username 进行排序要怎么写呢?
小程序云开发 聚合aggregate 先group,再sort排序
最新推荐文章于 2022-10-08 17:31:15 发布