npm.io
0.4.0 • Published 7 years ago

serviser-bookshelf

Licence
GPL-3.0
Version
0.4.0
Deps
6
Size
43 kB
Vulns
2
Weekly
0

Bookshelf with registry & virtuals & visibility & pagination & paranoia & eloquent plugins.

const Service = require('serviser');
const config = require('serviser-config');
const bookshelfBuilder = require('serviser-bookshelf');

const bookshelf = bookshelfBuilder({/*knex options*/});

const service = new Service(config);

//enables integrity inspection features
service.resourceManager.register('postgres', bookshelf);


//instantiates model definitions and registers them with  the `registry` plugin interface
//returns object with loaded models
bookshelf.loadModels([
    'path/to/directory/with/model/definitions'
]);

Model definition example eg.: lib/models/orm/user.js


module.exports = function(bookshelf) {

    return bookshelf.Model.extend({
        tableName: 'user'
    });
};

Keywords