聚合的四个关键字 count,distinct,group,mapReduce1
2
3
4
5
6
7
8
9db.user.find();
{_id: ObjectId(0000000000000000001)', name: 'alan', age: 20}
{_id: ObjectId(0000000000000000002)', name: 'wei', age: 21}
{_id: ObjectId(0000000000000000003)', name: 'Lee', age: 23}
{_id: ObjectId(0000000000000000004)', name: 'Fee', age: 20}
{_id: ObjectId(0000000000000000005)', name: 'D.D.', age: 23}
{_id: ObjectId(0000000000000000006)', name: 'Cd', age: 20}
count
1 | db.user.count() |
distinct
1 | db.user.distinct('age') |
group
1 | db.user.group({ |
1 | db.user.group({ |
mapReduce
the process: