hapi-shelf
hapi-shelf is a Hapi plugin for Bookshelf.js, an ORM for RDBMS.
Usage
Install hapi-shelf into your hapi project folder:
npm install hapi-shelf --save
Register the plugin with the server:
'use strict'; const Hapi = ;const HapiShelf = ; const server = ; server;
Options
knex
- (required) the knex configuration object.plugins
- an optional array of strings. Defaults to['registry']
.models
- an optional array of model strings.
Models
Models are registered automatically upon plugin registration if defined
in options.models
, using relative paths.
Models are defined as follows.
'use strict'; module { const MyModel = bookshelfModel; return bookshelf;};
Access this model in your route
'use strict'; const MyModel = serverplugins'hapi-shelf'; server;
Attributes are exposed as camelCase
, and saved to the DB as under_score
.
For details refer to Bookshelf Models.