@funcmaticjs/mongodb-plugin

0.0.6 • Public • Published

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 in ctx.state before this middleware runs. This property is useful if you want to mock ctx.state.mongodb.

Readme

Keywords

none

Package Sidebar

Install

npm i @funcmaticjs/mongodb-plugin

Weekly Downloads

7

Version

0.0.6

License

MIT

Unpacked Size

9.38 kB

Total Files

8

Last publish

Collaborators

  • danieljyoo