![k7 Logo](https://github.com/thebergamo/k7/raw/HEAD/images/k7.png)
hapi database connector
![js-semistandard-style](https://img.shields.io/badge/code%20style-semistandard-brightgreen.svg?style=flat-square)
K7 is the simplest way to connect Hapi.js with your favorite Database Mapper, you can use any of ours available connectors for the most populars Databases.
Example Usage
For example:
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:
- Setting the k7-mongoose adapter
- Setting the connectionString for mongoose connect
- Register the k7 to Hapi.js
Adapters
Write your own adapter
The K7 API is very simple, your adapter just need be a Class and export a function load
and return an Object with all models and the Database Mapper instance for k7 decorate the database in Hapi.js.
For more examples, please see the source code in the k7-sequelize plugin.
Testing
For testing you just need clone this repo and run npm install && npm test
inside root folder of this project.;