1 下载

https://www.mongodb.com/download-center/community

比如:

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.9.tgz

2 连接

# cd $MONGODB_HOME
# bin/mongo master:27017/database_name

3 查询

1 count

>db.getCollection('table_name').find({}).count()

2 group by

>db.getCollection('table_name').aggregate([{"$group": {_id: "$column_name", count: {"$sum": 1}}}])

3 select by limit

>db.getCollection('table_name').find({}).limit(1).pretty()

4 select by condition ‘=’

>db.getCollection('table_name').find({"column_name": "column_value"})

5 select by condition ‘>’

>db.getCollection('table_name').find({"column_name":{$gt:"column_value"}}).pretty()

6 select by condition ‘or’

>db.getCollection('table_name').find({$or: [ {"column_name1":"column_value1"},{"column_name2":{$gt:"column_value2"}}]}).pretty()

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄