MongoDBModule

mongodb. MongoDBModule

Represents a single MongoDB server instance

Constructor

new MongoDBModule()

Source:

Extends

  • AbstractModule

Members

ObjectId :ObjectIdUtils

Description:
  • ObjectId utility functions
Source:
ObjectId utility functions
Type:
  • ObjectIdUtils

client :external:MongoDBMongoClient

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

Methods

(async) connect() → {Promise}

Description:
  • Connects to the database
Source:
Returns:
Type
Promise

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

Description:
  • Removes an existing object from the database
Source:
See:
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}

Description:
  • Removes multiple objects from the database
Source:
See:
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}

Description:
  • Retrieves a new object from the database
Source:
See:
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}

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

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

Description:
  • Returns the relevant AdaptError instance to match the MongoError
Source:
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}

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

(async) init()

Source:

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

Description:
  • Adds a new object to the database
Source:
See:
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)

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

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

Description:
  • Replaces an existing object in the database
Source:
See:
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}

Description:
  • Set an index on a MongoDB collection
Source:
See:
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}

Description:
  • Updates an existing object in the database
Source:
See:
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