New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hapi-mongoose

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi-mongoose

Hapi Plugin to handle Mongoose handshake and initial setup

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

hapi-mongoose

Circle CI

Stories in Ready

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 = new Hapi.Server();

await server.register({
    plugin: require('hapi-mongoose'),
    options: options
});

const db = server.plugins['hapi-mongoose'].connection;

const mongoose = server.plugins['hapi-mongoose'].lib;

Example

const db = server.plugins['hapi-mongoose'].connection; // Get the current connection for this server instance
const mongoose = server.plugins['hapi-mongoose'].lib;
const Schema = mongoose.Schema;

const tankSchema = new Schema({
  //tank props
});

const Tank = db.model('Tank', tankSchema);

const small = new Tank({ size: 'small' });

small.save(function (err) {
  if (err) return handleError(err);
  // saved!
});

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

Keywords

FAQs

Package last updated on 23 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc