Mongo-Interlude
Lightweight npm package to provide cleaning operations with mongodb easily.
Core purpose of mongo-interlude is to help developers clean-up models in mongodb after or even before tests, to avoid Errors
For now, can be installed with npm:
$ npm install mongo-interlude
... and for dev dependency:
$ npm install -D mongo-interlude
Usage
For now available clearDb
module, which removes all data from all your models. Require mongoose
adapter.
// require main moduleconst mongoInterlude = // require clearDb function// notice that clearDb returns Promiseconst clearDb = mongoInterludeclearDb ...// e.g. you have after tests function:...
Params
mongoose
- your mongoose adaptersilent
- off loggingwhitelist
- array of model names, which will stay untouched
Return
clearDb
also return Object
, which contains Success
and Errors
Arrays:
...const result = await console/*success: [...], <- contains names of successfully cleared modelserrors: [...] <- contains objects with key of failed model and value of error*/...