MongoDB.getConnection()

Get an active connection to the database.

Depending on what driver this is, and the config of the specified connection manager, `getConnection()` may involve opening a new connection, aquiring an already-open connection from an existing pool, or even just returning a mock connection (e.g. a dictionary containing host/port/credentials-- for connection-less database servers like ElasticSearch).

Usage

Hover over inputs/exits for more info.

var MongoDB = require('machinepack-mongodb');


// Get an active connection to the database.

MongoDB.getConnection({

manager: '===',

meta: '===',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Could not acquire a connection to the database via the provided connection manager.

failed: function (result) {

 

},

// OK.

success: function (result) {

 

},

});

Inputs

manager required

The connection manager instance to acquire the connection from.

'==='
meta

Additional stuff to pass to the driver.

'==='

Exits

error

An unexpected error occurred.

failed

Could not acquire a connection to the database via the provided connection manager.

{ error: '===', meta: '===' }
success

OK.

'==='