Skip to content

antoniogiordano/mongo-clean

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongo-clean

Build Status

Clean all the collections in a mongo database

Install

npm install mongo-clean --save-dev

Usage

Reusing the same client:

var clean = require('./')
var MongoClient = require('mongodb').MongoClient
var url = "mongodb://localhost:27017/mongocleantest"

MongoClient.connect(url, { w: 1 }, function (err, db) {
  clean(db, function () {
    // your db is clean!
  })
})

Creating a new client:

var clean = require('./')
var url = "mongodb://localhost:27017/mongocleantest"

clean(url, function (err, db) {
  // automatically does MongoClient.connect for you
  // your db is clean!
})

Clean the db excluding a list of collections

var clean = require('./')
var MongoClient = require('mongodb').MongoClient
var url = "mongodb://localhost:27017/mongocleantest"

MongoClient.connect(url, { w: 1 }, function (err, db) {
  clean(db, {exclude: ['dummy1', 'dummy2']}, function () {
    // Delete all the collections in the db except dummy1 and dummy2
  })
})
var clean = require('./')
var url = "mongodb://localhost:27017/mongocleantest"

clean(url, {exclude: ['dummy1', 'dummy2']}, function (err, db) {
  // automatically does MongoClient.connect for you
  // Delete all the collections in the db except dummy1 and dummy2
})

License

MIT

About

Clean all the collections in a mongo database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%