mongodb-connection-simple
v1.2.0
Published
MongoDb Implementation that uses the same connection to save some performance. It is intended to be used as a singleton.
Downloads
1
Readme
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
async function method(){
await mongodb.connect();
const collection = mongodb.database.collection('test');
return await collection.find();
}