MongoDBClient

Hierarchy

Client

  • Client

    MongoDBClient

Implements

Index

Constructors

Properties

Accessors

Methods

Object literals

Constructors

constructor

+ new MongoDBClient(props: Partial‹MongoDBClient›): MongoDBClient

Overrides Client.constructor

Creates an instance of MongoDBClient. Creates an instance of MongoDBClient.

Parameters:

NameTypeDescription
propsPartial‹MongoDBClientProperties of the type required for construction.

Returns: MongoDBClient

Properties

Optional _library

_library? : MongoClient


databases

databases: MongoDBDatabaseConfig[]


id

id: string | Guid

Overrides Client.id


Optional options

options? : MongoClientOptions


state

state: State

Implementation of Client.state

Overrides Client.state


url

url: string


Static STATES

STATES: object

Inherited from Client.STATES

Overrides void

Type declaration:

  • connected: string

  • constructed: string

  • disconnected: string

  • failed: string

  • initialized: string

  • paused: string

  • stopped: string

Accessors

library

get library(): MongoClient

Gets library instance.

Returns: MongoClient

MongoClient instance.

Methods

connect

connect(): Promise‹void›

Implementation of Client

Connects to MongoDB.

async

throws {Error} Thrown if the connection to MongoDB cannot be established.

Returns: Promise‹void›


disconnect

disconnect(): Promise‹void›

Implementation of Client

Disconnects MongoDB client.

async

Returns: Promise‹void›


getCollection

getCollection(databaseName: string, collectionName: string): Collection

Returns collection from MongoClient.

Parameters:

NameTypeDescription
databaseNamestringDatabase name.
collectionNamestringCollection name.

Returns: Collection

Collection instance from MongoClient.


getDatabase

getDatabase(name: string): Db

Returns database from MongoClient.

Parameters:

NameTypeDescription
namestringDatabase name.

Returns: Db

Db instance from MongoClient.


getId

getId(): string | Guid

Implementation of Client

Inherited from Client.getId

Overrides void

Returns: string | Guid


getSelectableStates

getSelectableStates(): Record‹string, State

Implementation of Client

Inherited from StatefulMixin.getSelectableStates

Overrides Task.getSelectableStates

Returns: Record‹string, State


getState

getState(): State

Implementation of Client

Inherited from StatefulMixin.getState

Overrides Task.getState

Returns: State


hasState

hasState(): boolean

Implementation of Client

Inherited from StatefulMixin.hasState

Overrides Task.hasState

Returns: boolean


initialize

initialize(): Promise‹void›

Implementation of Client

Initializes client.

async

Returns: Promise‹void›


isConnected

isConnected(): boolean

Implementation of Client

Evaluates if client is connected to MongoDB.

Returns: boolean

Returns true if client is connected, else false.


isInOneOfStates

isInOneOfStates(states: State | State[]): boolean

Implementation of Client

Inherited from StatefulMixin.isInOneOfStates

Overrides Task.isInOneOfStates

Parameters:

NameType
statesState | State[]

Returns: boolean


isInState

isInState(state: State | State[]): boolean

Implementation of Client

Inherited from StatefulMixin.isInState

Overrides Task.isInState

Parameters:

NameType
stateState | State[]

Returns: boolean


reconnect

reconnect(): Promise‹void›

Implementation of Client

Reconnects to MongoDB.

async

Returns: Promise‹void›


setState

setState(state: State): void

Implementation of Client

Inherited from StatefulMixin.setState

Overrides Task.setState

Parameters:

NameType
stateState

Returns: void


validateState

validateState(stateOrStates: State | State[], error?: Error): boolean

Implementation of Client

Inherited from StatefulMixin.validateState

Overrides Task.validateState

Parameters:

NameType
stateOrStatesState | State[]
error?Error

Returns: boolean

Object literals

Static defaultOptions

defaultOptions: object

useNewUrlParser

useNewUrlParser: boolean = true

useUnifiedTopology

useUnifiedTopology: boolean = true