MongoDB查询语法

41 阅读1分钟

Limit

db.getCollection("x-x-x").find().limit(5)

Where

db.getCollection("x-x-x").find({"host":"x.com"}).limit(500)

GroupBy

db.getCollection("x-x-x").aggregate(
{"$match":{"host":"x.com"}},
{"$group":{"_id":"$json.type","count":{"$sum":1}}},
)

image.png

等效

select * from x-x-x where host="x.com" groupby "json.type"