mongo聚合命令

db.getCollection('chat').aggregate([
{
"$match": {
"last": 1,
"type": 0
}
},
{
$project:{giftId:1,text:1,userId:1,createAt:1}
},
{
$group:{
_id:'$giftId',
createAt:{$max:'$createAt'},
text:{$last:'$text'},
userId:{$last:'$userId'},
}
}
])

posted on 2018-09-10 11:34  断剑重铸之时  阅读(131)  评论(0编辑  收藏  举报