语法之 与sql等价运算

$match ========where

$project========as

$sort==========order by 

$group========group by 

$skip/$limit=====skip/limit

$lookup==========left outer join

 

举例说明;

sql 

select age,count(*) as a from user where fex='nv' group by age having count(*)<10

mongo

db.user.aggregate([{ $match:  {fix: nv}},{$group:{_id:'$age,a:{$sum: 1}}},{$mtch: {a: {$lt: 10}}}]);

 

 

特殊算法:

$facet

$bucket

$unwind  + 字段值

posted @ 2020-09-01 23:26  和尚也爱看AV  阅读(151)  评论(0)    收藏  举报