Collection stats mongodb
Document count, index sizes, storage for a collection
mongosh --eval 'db.myCollection.stats()' mongodb://mongo:27017/mydb
more mongodb
all 20 commands →
Current operations
mongosh --eval 'db.currentOp({active:true,secs_running:{$gt:5}})' mongodb://mongo:27017
Create dump
mongodump --uri='mongodb://user:pass@mongo:27017' --db=mydb --out=/backups/
Restore dump
mongorestore --uri='mongodb://user:pass@mongo:27017' --db=mydb /backups/mydb/
List indexes
mongosh --eval 'db.myCollection.getIndexes()' mongodb://mongo:27017/mydb
Connect with URI
mongosh 'mongodb+srv://user:pass@cluster.example.com/mydb'