Skip to content

Instantly share code, notes, and snippets.

@matteofigus
Created February 6, 2014 12:29
Show Gist options
  • Select an option

  • Save matteofigus/8843247 to your computer and use it in GitHub Desktop.

Select an option

Save matteofigus/8843247 to your computer and use it in GitHub Desktop.

Revisions

  1. matteofigus created this gist Feb 6, 2014.
    11 changes: 11 additions & 0 deletions mongo-ls.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    // 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');
    }