-
-
Save mandadimuralidharreddy/6d6bce4b4f871d457fd2d8d559e1ed27 to your computer and use it in GitHub Desktop.
A script to list all the collections and document count for a specific mongodb db
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage: mongo {Server without mongodb:// example 127.0.0.1:27017}/{DbName} [-u {Username}] [-p {Password}] < ./mongo-ls.js | |
var collections = db.getCollectionNames(); | |
print('Collections inside the db:'); | |
for(var i = 0; i < collections.length; i++){ | |
var name = collections[i]; | |
if(name.substr(0, 6) != 'system') | |
print(name + ' - ' + db[name].count() + ' records'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment