hapi-mongoose
Hapi Plugin to handle Mongoose handshake and initial setup
Install
npm install --save hapi-mongoose
Requirements
- Mongoose
npm install --save mongoose
Usage
const options = promises: 'native' uri: 'mongodb://localhost:27017'; const server = ; await server; const db = serverplugins'hapi-mongoose'connection; const mongoose = serverplugins'hapi-mongoose'lib;
Example
const db = serverplugins'hapi-mongoose'connection; // Get the current connection for this server instanceconst mongoose = serverplugins'hapi-mongoose'lib;const Schema = mongooseSchema; const tankSchema = //tank props; const Tank = db; const small = size: 'small' ; small;
It is important to use server.plugins['hapi-mongoose'].lib
instead of require('mongoose')
due to this issue.
Options
- promises - Choose your promises implementation. Valid string options are 'bluebird', 'native' (or 'es6'). Any other value will result in the use of mongoose's built in 'mpromise'. Read More
- uri - MongoDB uri
- mongooseOptions - A javascript opbject with mongoose connection options. Read More