k7-mongoose
k7
adapter for mongoose ODM
Lead Maintainer: Marcos Bérgamo
Example Usage
const Hapi = ;const Server = ; Server; let options = adapter: connectionString: 'mongodb://localhost:27017/K7Mongoose'; Server;
This example does the following:
- Setting the k7-mongoose adapter
- Setting the connectionString for mongoose connect
- 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.