MongoDbConnection class
MongoDB connection using plain driver.
By defining a connection and sharing it through multiple persistence components you can reduce number of used database connections.
Configuration parameters
- connection(s):
discovery_key
: (optional) a key to retrieve the connection from IDiscoveryhost
: host name or IP addressport
: port number (default: 27017)uri
: resource URI or connection string with all parameters in it
credential(s)
:store_key
: (optional) a key to retrieve the credentials from ICredentialStoreusername
: (optional) user namepassword
: (optional) user password
- options:
max_pool_size
: (optional) maximum connection pool size (default: 2)keep_alive
: (optional) enable connection keep alive (default: true)connect_timeout
: (optional) connection timeout in milliseconds (default: 5000)socket_timeout
: (optional) socket timeout in milliseconds (default: 360000)auto_reconnect
: (optional) enable auto reconnection (default: true)reconnect_interval
: (optional) reconnection interval in milliseconds (default: 1000)max_page_size
: (optional) maximum page size (default: 100)replica_set
: (optional) name of replica setssl
: (optional) enable SSL connection (default: false)auth_source
: (optional) authentication sourcedebug
: (optional) enable debug output (default: false).
References
- *:logger:*:*:1.0 (optional) ILogger components to pass log messages
- *:discovery:*:*:1.0 (optional) IDiscovery services
- *:credential-store:*:*:1.0 (optional) Credential stores to resolve credentials
Constructors
- MongoDbConnection()
- Creates a new instance of the connection component.
Properties
- connection ↔ Db?
-
The MongoDb database object.
getter/setter pair
- connectionResolver ↔ MongoDbConnectionResolver
-
The connection resolver.
getter/setter pair
- databaseName ↔ String?
-
The MongoDB database name.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger ↔ CompositeLogger
-
The logger.
getter/setter pair
- options ↔ ConfigParams
-
The configuration options.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
close(
String? correlationId) → Future - Closes component and frees used resources.
-
configure(
ConfigParams config) → void - Configures component by passing configuration parameters.
-
getConnection(
) → dynamic -
getDatabaseName(
) → String? -
isOpen(
) → bool - Checks if the component is opened.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
open(
String? correlationId) → Future - Opens the component.
-
setReferences(
IReferences references) → void - Sets references to dependent components.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited