mocha-mongodb
MongoDB helper for Mocha. Useful for seeding data for API tests.
Installation
npm install mocha-mongodb --save-dev
Example Usage
var db = ; ;
Methods
connect(mongoUrl, [options={}])
Description
Connect to the specified database. Runs in a "before" block. Assigns the database connection instance to this.db
. Can take an optional options
object (see below).
Example
db;
Options
### create(collection, query)
Alias
add
, create
Description Create a new object in a collection. Runs in a "beforeEach" block.
Example
db;// db.add('user', { firstName: 'John', lastName: 'Smith' });
### remove(collection, query)
Alias
delete
, remove
Description Remove objects from a collection. Runs in a "beforeEach" block.
Example
db;// db.delete('user', { firstName: 'John' });
## dropDb()
Description Drops the current database. Runs in a "beforeEach" block.
Example
db;