mongo基本操作
1.安装mongo客户端
参考:ubuntu安装mongodb-4.4(通过apt命令)
2.连接mongodb
mongo ip:27017/db_name -u user_name -p
3.创建collection
参考:MongoDB 教程
use xx_db
db.createCollection("xx_collection")
4.插入数据
insert one
use xx_db
db.xx_collection.insertOne(
{
"id":"100000",
"time":new Date(),
"abc":"123456"
}
)
insert many
db.xx_collection.insertMany(
[
{
"id":"200000",
"time":new Date(),
"token":"1111111"
}, {
"id":"300000",
"time":new Date(),
"token":"2222222"
}
]
)
5.删除数据
delete one
use xx_db
db.xx_collection.deleteOne({'id':'200000'})
delete many
db.xx_collection.deleteMany({'token':'1111111'})
6.查看Mongo的collection大小
db.getCollection("your_collection").stats()

7.查看collection是否是sharded
db.getCollection("your_collection").stats()
没有sharded字段,或者sharded值为false,都不是sharded collection

本文只发表于博客园和tonglin0325的博客,作者:tonglin0325,转载请注明原文链接:https://www.cnblogs.com/tonglin0325/p/5287523.html

浙公网安备 33010602011771号