Socket
Socket
Sign inDemoInstall

k7-mongoose

Package Overview
Dependencies
60
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    k7-mongoose

K7 Adapter for using mongoose


Version published
Weekly downloads
12
Maintainers
1
Install size
6.72 MB
Created
Weekly downloads
 

Readme

Source

k7-mongoose

k7 adapter for mongoose ODM

Build Status

Lead Maintainer: Marcos Bérgamo

Example Usage

const Hapi = require('hapi');
const Server = new Hapi.Server();

Server.connection({host: 'localhost'});

let options = {
    adapter: require('k7-mongoose'),
    connectionString: 'mongodb://localhost:27017/K7Mongoose'
};

Server.register({
    register: require('k7'),
    options: options
}, (err) => {
    if (err) {
        throw err;
    }
    
    Server.start((err) => {
        if (err) {
            throw err;
        }
        
        Server.log('info', 'Server running at: ' + Server.info.uri);
    });
});

This example does the following:

  1. Setting the k7-mongoose adapter
  2. Setting the connectionString for mongoose connect
  3. Register the k7 to Hapi.js

Options

All the options available in Mongoose can be setted in connectionOptions.

Set up the models

You can define your models schema like you're already do, but you need to replace the const mongoose = require('mongoose'); on top of your models by update with const mongoose = require('k7-mongoose').mongoose();

Why this is required? Because mongoose is a singleton, therefore you need to use the k7-mongoose instantiated version.

Keywords

FAQs

Last updated on 20 Mar 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc