Mongo Client Connect
Reuses the same connection objects (creating only one connection pool per connectionURI) and collection instances, avoiding the creation of many, unnecessary, connections pools to a same connectionURI.
It also provides an easy way to specify N collections from N connectionURIs to be retrieved at once, in one call (DRY!).
Mongo DB Native NodeJS Driver is the engine under the hood.
npm install mongo-client-connect
OBS: Examples are created for Nodejs v6+ (Destructuring!).
Connect to a MongoDB
A simple connection to a MongoDB
But in case you have more than one call in your project:
// Somewhere;//[...]// Somewhere else...;
by mistake, or intentionally because of by some file structure strategy, only one connection pool will be created
Connect to many MongoDBs
A simple connection to N MongoDBs
Connect and gets Collections
It will connect and return the collections that has been asked for.
Connect to many DBs and get Collections
It connects to N MongoDBs and returns collections for each of them.
Connect and gets Collections (by
It will connect and return collections, the same as above, but the collections are specified by an
Object, in case you prefer the response to be an Object. The collections can also be configured with an alias.
Connect to many DBs and get Collections (by
Same as above, it connects to N MongoDBs and returns collections for each of them, but defining collections as an
Object in case you prefer the response to be an Object. The collections can also be configured with an alias.