MongoDBClient
Hierarchy
↳ Client
Client
↳ MongoDBClient
Implements
Index
Constructors
Properties
Accessors
Methods
- connect
- disconnect
- getCollection
- getDatabase
- getId
- getSelectableStates
- getState
- hasState
- initialize
- isConnected
- isInOneOfStates
- isInState
- reconnect
- setState
- validateState
Object literals
Constructors
constructor
+ new MongoDBClient(props
: Partial‹MongoDBClient›): MongoDBClient
Overrides Client.constructor
Creates an instance of MongoDBClient. Creates an instance of MongoDBClient.
Parameters:
Name | Type | Description |
---|---|---|
props | Partial‹MongoDBClient› | Properties of the type required for construction. |
Returns: MongoDBClient
Properties
Optional
_library
• _library? : MongoClient
databases
• databases: MongoDBDatabaseConfig[]
id
• id: string | Guid
Optional
options
• options? : MongoClientOptions
state
• state: State
Implementation of Client.state
url
• url: string
Static
STATES
▪ STATES: object
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:
Name | Type | Description |
---|---|---|
databaseName | string | Database name. |
collectionName | string | Collection name. |
Returns: Collection
Collection
instance from MongoClient.
getDatabase
▸ getDatabase(name
: string): Db
Returns database from MongoClient.
Parameters:
Name | Type | Description |
---|---|---|
name | string | Database name. |
Returns: Db
Db
instance from MongoClient.
getId
▸ getId(): string | Guid
Implementation of Client
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
Returns: State
hasState
▸ hasState(): boolean
Implementation of Client
Inherited from StatefulMixin.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:
Name | Type |
---|---|
states | State | State[] |
Returns: boolean
isInState
▸ isInState(state
: State | State[]): boolean
Implementation of Client
Inherited from StatefulMixin.isInState
Parameters:
Name | Type |
---|---|
state | State | 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
Parameters:
Name | Type |
---|---|
state | State |
Returns: void
validateState
▸ validateState(stateOrStates
: State | State[], error?
: Error): boolean
Implementation of Client
Inherited from StatefulMixin.validateState
Overrides Task.validateState
Parameters:
Name | Type |
---|---|
stateOrStates | State | State[] |
error? | Error |
Returns: boolean
Object literals
Static
defaultOptions
▪ defaultOptions: object
useNewUrlParser
• useNewUrlParser: boolean = true
useUnifiedTopology
• useUnifiedTopology: boolean = true