Collection stats
Document count, index sizes, storage for a collection
mongosh --eval 'db.myCollection.stats()' mongodb://mongo:27017/mydb
More mongodb commands
-
mongosh --eval 'db.currentOp({active:true,secs_running:{$gt:5}})' mongodb://mongo:27017Show operations running longer than 5 seconds
-
mongodump --uri='mongodb://user:pass@mongo:27017' --db=mydb --out=/backups/Export database to BSON files
-
mongorestore --uri='mongodb://user:pass@mongo:27017' --db=mydb /backups/mydb/Import BSON backup into MongoDB
-
mongosh --eval 'db.myCollection.getIndexes()' mongodb://mongo:27017/mydbShow all indexes on a collection
-
mongosh 'mongodb+srv://user:pass@cluster.example.com/mydb'Connect to Atlas or any MongoDB URI with mongosh