mongo aggregate查询:
db.collection.aggregate({
$group:{
_id:"$id", //"$_id"代表引用集合中_id列
max_value:{$max:"$times"} //"$times"代表引用集合中times列
},
$match:{times:{$gte:100}}
})相当于sql查询:
select _id, max(times) from collection where times>=100
本文出自 “架构师之路” 博客,请务必保留此出处http://lizhuquan0769.blog.51cto.com/2591147/1763652
原文地址:http://lizhuquan0769.blog.51cto.com/2591147/1763652