mongodb-connection
MongoDb Implementation that uses the same connection to save some performance. It is intended to be used as a singleton.
How to install
npm install --save mongodb-connection
MongoDbConnection
Main implementation class.
Parameters:
- servers: An array of objetcs with server information (Example: { host: 'localhost', port: 27017}) or the mongodb uri
- databaseName: Name of the database to connect.
- options: MongoDB client options
Methods
- connect(options): Verifies if there is not a current connection and creates one if there is not.
Example - Promise
{ await mongodb; const collection = mongodbdatabase; return await collection;}