@funcmaticjs/mongodb-plugin
v0.0.6
Published
Funcmatic middleware that creates and manages a MongoDB connection
Downloads
3
Readme
mongodb-plugin
Funcmatic plugin that creates and manages a MongoDB connection
Install
$> npm install --save @funcmaticjs/mongodb-plugin
Use
const func = require('@funcmaticjs/funcmatic')
const MongoDBPlugin = require('@funcmaticjs/mongodb-plugin')
...
func.use(new MongoDBPlugin())
Environment
The following variables must exist in ctx.env
during the env handler:
FUNC_MONGODB_URI
: A MongoDB connection string.FUNC_MONGODB_CACHE_CONNECTION
(OPTIONAL): If it is set to the string 'false', then the plugin will establish and close a connection on every request.
Side Effects
ctx.state.mongodb
: The MongoDB DB instance. Will NOOP if ctx.state.mongodb is already defined inctx.state
before this middleware runs. This property is useful if you want to mockctx.state.mongodb
.