MongoDBModule

mongodb. MongoDBModule

Represents a single MongoDB server instance

Constructor

new MongoDBModule()

Source:

Extends

  • AbstractModule

Members

client :external:MongoDBMongoClient

Source:
Reference to the MongDB client
Type:
  • external:MongoDBMongoClient

ObjectId :ObjectIdUtils

Source:
ObjectId utility functions
Type:
  • ObjectIdUtils

Methods

(async) connect() → {Promise}

Source:
Connects to the database
Returns:
Type
Promise

(async) delete(collectionName, query, options) → {Promise}

Source:
See:
Removes an existing object from the database
Parameters:
Name Type Description
collectionName String The name of the MongoDB collection
query Object
options external:MongoDBDeleteOptions Options to pass to the MongoDB driver
Returns:
promise
Type
Promise

(async) deleteMany(collectionName, query, options) → {Promise}

Source:
See:
Removes multiple objects from the database
Parameters:
Name Type Description
collectionName String The name of the MongoDB collection
query Object
options external:MongoDBDeleteOptions Options to pass to the MongoDB driver
Returns:
promise
Type
Promise

(async) find(collectionName, query, options) → {Promise}

Source:
See:
Retrieves a new object from the database
Parameters:
Name Type Description
collectionName String The name of the MongoDB collection
query Object
options external:MongoDBFindOptions Options to pass to the MongoDB driver
Returns:
promise
Type
Promise

getCollection(collectionName) → {external:MongoDBCollection}

Source:
See:
Returns the associated MongoDB collection
Parameters:
Name Type Description
collectionName String The name of the MongoDB collection
Returns:
Type
external:MongoDBCollection

getError(collectionName, action, error) → {AdaptError}

Source:
Returns the relevant AdaptError instance to match the MongoError
Parameters:
Name Type Description
collectionName String DB collection being processed
action String DB action being performed
error String The error message
Returns:
Type
AdaptError

(async) getStats() → {Promise}

Source:
See:
Get all the db statistics
Returns:
Type
Promise

(async) init()

Source:

(async) insert(collectionName, data, options) → {Promise}

Source:
See:
Adds a new object to the database
Parameters:
Name Type Description
collectionName String The name of the MongoDB collection
data Object
options external:MongoDBInsertOneOptions Options to pass to the MongoDB driver
Returns:
promise
Type
Promise

parseOptions(options)

Source:
Makes sure options are in the correct format.
Parameters:
Name Type Description
options Object The options to parse

(async) replace(collectionName, query, data, options) → {Promise}

Source:
See:
Replaces an existing object in the database
Parameters:
Name Type Description
collectionName String The name of the MongoDB collection
query Object
data Object
options external:MongoDBFindOneAndReplaceOptions Options to pass to the MongoDB driver
Returns:
promise
Type
Promise

(async) setIndex(collectionName, fieldOrSpec, options) → {Promise}

Source:
See:
Set an index on a MongoDB collection
Parameters:
Name Type Description
collectionName String The name of the MongoDB collection
fieldOrSpec String | Array | Object Definition of the index
options external:MongoDBCreateIndexesOptions Options to pass to the MongoDB driver
Returns:
Type
Promise

(async) update(collectionName, query, data, options) → {Promise}

Source:
See:
Updates an existing object in the database
Parameters:
Name Type Description
collectionName String The name of the MongoDB collection
query Object
data Object
options external:MongoDBFindOneAndUpdateOptions Options to pass to the MongoDB driver
Returns:
promise
Type
Promise