Gathering detailed insights and metrics for mongo-cleaner
Gathering detailed insights and metrics for mongo-cleaner
Gathering detailed insights and metrics for mongo-cleaner
Gathering detailed insights and metrics for mongo-cleaner
cleaner-wrasse
node mongo express handlebars issue tracking CRUD
string_cleaner
A basic cleaner for mongo and sql with a hash function
mongoose-setup
plugin for cleaner mongoose setups
setup-mongodb
This plugin allows you to setup multiple mongoDB in a cleaner way and ensures DB is connected before accessing it.
npm install mongo-cleaner
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (86.89%)
JavaScript (13.11%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
GPL-3.0 License
1 Stars
138 Commits
2 Watchers
2 Branches
1 Contributors
Updated on Feb 19, 2023
Latest Version
4.0.3
Package Id
mongo-cleaner@4.0.3
Unpacked Size
0.98 MB
Size
327.17 kB
File Count
8
NPM Version
8.19.2
Node Version
18.12.1
Published on
Feb 19, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
An npm module to quickly clean your mongodb, both from code and cli.
To install mongo-cleaner as a local module:
1$ npm install mongo-cleaner
To install mongo-cleaner as a global module:
1$ npm install -g mongo-cleaner
1const mongoCleaner = require('mongoCleaner'); 2await mongoCleaner.clean();
1const mongoCleaner = require('mongoCleaner'); 2const uri = 'mongodb://localhost:27017'; 3const mongoClientOptions = { numberOfRetries: 10 }; 4 5await mongoCleaner.clean(uri, mongoClientOptions);
1const mongoCleaner = require('mongoCleaner'); 2const options = { 3 noConfirm: false, 4 log: true 5}; 6 7await mongoCleaner.clean(null, null, options);
1const mongoCleaner = require('mongoCleaner'); 2const options = { 3 keep: ['animals', /test$/] 4}; 5 6await mongoCleaner.clean(null, null, options);
1const mongoCleaner = require('mongoCleaner'); 2const options = { 3 dropDatabases: false, 4 emptyDatabases: false, 5 emptyCollections: true 6}; 7 8await mongoCleaner.clean(null, null, options);
1const mongoCleaner = require('mongoCleaner'); 2const options = { 3 dropDatabases: true, 4 emptyDatabases: true, 5 emptyCollections: true 6}; 7 8await mongoCleaner.clean(null, null, options);
1const mongoCleaner = require('mongoCleaner'); 2const options = { 3 throwIfNotTotal: true 4}; 5 6await mongoCleaner.clean(null, null, options);
1$ mongo-cleaner clean
This way everything on mongodb://localhost:27017
will be cleaned
1$ mongo-cleaner clean -y
This way no proceeding-confirmation will be asked.
1$ mongo-cleaner clean --keep first second /test$/i
This way first, second and all databases that end with "test" (case-insensitive) will be keeped.
1$ mongo-cleaner clean --uri mongodb://localhost:8080
This way everything on mongodb://localhost:8080
will be cleaned.
1$ mongo-cleaner clean --host localhost --port 27017 --username euber --password secret --srv
This way everything on srv+mongodb://euber:pass@localhost:27017
will be cleaned.
1$ mongo-cleaner clean -o mongo-cleaner.config.json -y
This way options will be taken by the file ./mongo-cleaner.config.json
. These options do not overwrite
the command ones, so in every case of this example no confirmation to proceed will be asked.
1$ mongo-cleaner --help
Syntax:
mongoCleaner.clean(uri, connectionOptions, options)
Description:
Tries to remove all the databases of MongoDB. The function is asynchronous and returns nothing. See Usage to have an example.
Parameters:
string
uri of the mongodb connection. Default: mongodb://localhost:27017
.MongoClientOptions
. By default, if not explicitly set to false, "useUnifiedTopology" and "useNewUrlParser" are set to true.MongoCleanerOptions
object for the cleaner. You can specify things such as asking a confirm before cleaning, databases to be kept, keeping collections and removing their documents.MongoCleanerOptions parameters:
true
. If you want the method to skip asking confirm before cleaning the MongoDB.[]
. A string
, a RegExp
, a (db: name) => boolean
or an array of all of them
specifying databases that will not be cleaned.false
. If you want to display the clean method's log on console.true
. If you want to drop the whole database. NB: The admin database cannot be dropped and is ignored.false
. If you want to drop databases' collections without dropping the databases. If both "dropDatabases" and this options are true, this option will be used as a fallback if a database drop fails.false
. If you want to empty collections without dropping them and their databases. If both "emptyDatabases" and this options are true, this option will be used as a fallback if a collection drop fails. NB: If "dropDatabases", "emptyDatabases" and "emptyCollections" are all false, this option will eventually become true.1
. The number of times a drop or empty operation is retried before throwing an error or passing to a fallback.20
. The number of milliseconds between two attempts of a drop or empty operation.false
. If you want to throw a MongoCleanerCleanError
when MongoDB is only partially cleaned.Made with dree
mongo-cleaner
├── .eslintignore
├── .eslintrc.cjs
├── .prettierrc.cjs
├── LICENSE
├── README.md
├── babel.config.cjs
├── build.mjs
├─> docs
│ └─> tree
│ └── dree.config.json
├── jest.config.ts
├── package-lock.json
├── package.json
├─> source
│ ├─> bin
│ │ ├── .eslintrc.cjs
│ │ ├── index.ts
│ │ └─> utils
│ │ └── index.ts
│ ├─> lib
│ │ ├─> errors
│ │ │ ├── index.ts
│ │ │ ├── mongoCleanerCleanError.ts
│ │ │ ├── mongoCleanerConnectionError.ts
│ │ │ ├── mongoCleanerDisconnectionError.ts
│ │ │ ├── mongoCleanerError.ts
│ │ │ ├── mongoCleanerListCollectionsError.ts
│ │ │ └── mongoCleanerListDatabasesError.ts
│ │ ├── index.ts
│ │ ├─> types
│ │ │ ├── exported.ts
│ │ │ ├── index.ts
│ │ │ └── internal.ts
│ │ └─> utils
│ │ ├── askConfirm.ts
│ │ ├── cleaner.ts
│ │ ├── logger.ts
│ │ └── options.ts
│ └── tsconfig.json
├─> test
│ ├── .eslintrc.cjs
│ ├── askConfirm.test.ts
│ ├── clean.test.ts
│ ├── errors.test.ts
│ ├── logger.test.ts
│ ├─> mock
│ ├── options.test.ts
│ └─> utils
│ ├── mockAskConfirm.ts
│ └── mockOra.ts
├── tsconfig.json
├── typedoc.cjs
└── typedoc.dev.cjs
To build the module make sure you have the dev dependencies installed.
The project is written in Typescript
, bundled with Webpack
and linted with ESLint
.
In order to lint the code:
1$ npm run lint
In order to lint and fix the code:
1$ npm run lint:fix
There are also the :source
and :test
suffix after lint
in order to lint only the source code or the test code.
To transpile the source code:
1$ npm run transpile
The source
folder will be transpiled in the dist
folder. Also the type declarations
will be generated.
Note: Running tests will delete permanently your MongoDB data. Do not do it if you have important data on it.
After having transpiled the code, run:
1$ npm test
in order to run the tests with mocha
.
If a coverage report is to be generated, run:
1$ npm run nyc
1$ npm run bundle
The source
folder will be compiled in the bundled
folder. It will contain the bundled lib/index.js
, lib/index.d.ts
and bin/index.js
files.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no SAST tool detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
14 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More