Class: MongoCollectionFake

MongoCollectionFake()

Fake for the standard Mongo Collection module. Documents are stored in memory.

Constructor

new MongoCollectionFake()

Source:

Methods

drop() → {Promise.<T>}

removes all stored documents

drop

Source:
Returns:
Type
Promise.<T>

find(query) → {MongoCursorFake}

find documents in the database

find

Parameters:
Name Type Description
query

currently has support for the following (anything else will be ignored and all documents will be returned)

  • no query, i.e. return all documents
  • '$or' type queries for strict equality, e.g. {$or [ {name: 'rimmer'}, {rank: 'third technician'} ] }
Source:
Returns:
Type
MongoCursorFake

insertMany(docs) → {Promise.<{insertedCount}>}

insert documents into the database

insertMany

Parameters:
Name Type Description
docs

Array of objects

Source:
Returns:
Type
Promise.<{insertedCount}>

updateMany(filter, update, options) → {Promise.<T>}

update many documents in the database

updateMany

Parameters:
Name Type Description
filter

currently has support for the following (anything else will be ignored and all documents will be updated)

  • no query, i.e. return all documents
  • '$or' type queries for strict equality, e.g. {$or [ {name: 'rimmer'}, {rank: 'third technician'} ] }
update

Supports $set

options

ignored

Source:
Returns:
Type
Promise.<T>