mongdb group 分组查询技巧
db.getCollection('xxx').aggregate([ { $match : { uid :42 } }, {$group : { _id : "$device_token", num_tutorial : {$sum : 1} } } ])
等于 mysql 的 SELECT _id, count(*) AS num_tutorial FROM xxx WHERE uid =42 GROUP BY device_token
mongdb group 分组查询技巧
db.getCollection('xxx').aggregate([ { $match : { uid :42 } }, {$group : { _id : "$device_token", num_tutorial : {$sum : 1} } } ])
等于 mysql 的 SELECT _id, count(*) AS num_tutorial FROM xxx WHERE uid =42 GROUP BY device_token