[AppleScript] 纯文本查看 复制代码
db.stu.aggregate({$group:{_id:"$name",counter:{$sum:2}}})
db.stu.aggregate({$group:{_id:null,counter:{$sum:1}}})
db.stu.aggregate({$group:{_id:"$gender",name:{$push:"$name"}}})
db.stu.aggregate({$group:{_id:"$gender",name:{$push:"$$ROOT"}}})
db.tv3.aggregate(
{$group:{_id:{"country":"$country",province:"$province",userid:"$userid"}}},
{$group:{_id:{country:"$_id.country",province:"$_id.province"},count:{$sum:1}}},
{$project:{country:"$_id.country",province:"$_id.province",count:"$count",_id:0}}
)
db.stu.aggregate(
{$match:{age:{$gt:20}}},
{$group:{_id:"$gender",count:{$sum:1}}}
)
db.t2.aggregate(
{$unwind:"$size"}
)
db.t3.aggregate(
{$unwind:"$tags"},
{$group:{_id:null,count:{$sum:1}}}
)
db.t3.aggregate(
{$unwind:{path:"$size",preserveNullAndEmptyArrays:true}}
)