Skip to content

Instantly share code, notes, and snippets.

@dimi-kr
Forked from BlakeGardner/compact.js
Created May 18, 2018 09:02
Show Gist options
  • Select an option

  • Save dimi-kr/e5143bff7f90888b16d7d2c0038b1f30 to your computer and use it in GitHub Desktop.

Select an option

Save dimi-kr/e5143bff7f90888b16d7d2c0038b1f30 to your computer and use it in GitHub Desktop.

Revisions

  1. @BlakeGardner BlakeGardner revised this gist Jan 21, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions compact.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    // This script loops though the list of collection names in a MongoDB and runs the compact operation on them
    // Simply paste this into the Mongo shell

    use testDbName;
    db.getCollectionNames().forEach(function (collectionName) {
  2. @BlakeGardner BlakeGardner created this gist Jan 21, 2014.
    6 changes: 6 additions & 0 deletions compact.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@

    use testDbName;
    db.getCollectionNames().forEach(function (collectionName) {
    print('Compacting: ' + collectionName);
    db.runCommand({ compact: collectionName });
    });