2.1.0 • Published 8 years ago
steeplejack-mongodb v2.1.0
Steeplejack MongoDB
MongoDB implementation for steeplejack projects
Usage
This is a very thin wrapper for the MongoDB MongoClient.connect. It configures an instance of the MongoDB driver wrapped in generic-pool class for easy connection pooling.
This configures a Steeplejack injectable module called $mongodbDriver
.
// Configure a factory dependency
export let __factory = {
name: "$mongodbResource",
factory: ($mongodbDriver) => {
let poolOptions = {};
let mongoOptions = {};
let mongoUrl = "mongodb://localhost/db";
return $mongodbDriver({
url: mongoUrl,
poolOptions,
mongoOptions
});
}
};
The poolOptions
accepts anything that the generic-pool
takes.
The mongoOptions
accepts anything that the
MongoClient.connect options take.
Dependencies
This requires an object called StoreError
to be registered to the Dependency Injector. You can either create your own
or use the Steeplejack Errors package