FS1360472174 / nosql-mongo

mongo knowledge
4 stars 4 forks source link

Mongo Aggregation #5

Closed FS1360472174 closed 7 years ago

FS1360472174 commented 7 years ago

issues

FS1360472174 commented 7 years ago

1.db.collections.aggregate( [ {$match:{}}, $group:{} ] )

先做匹配,再做聚合 mongo-aggregation-pipeline

FS1360472174 commented 7 years ago

{ _id : "jane", joined : ISODate("2011-03-02"), likes : ["golf", "racquetball"] }

db.users.aggregate( [ { $project : { name:{$toUpper:"$_id"} , _id:0 } }, { $sort : { name : 1 } } ]

$project 可以重命名字段