https://github.com/lucid-services/serviser-bookshelf
Integrates bookshelf ORM with serviser
https://github.com/lucid-services/serviser-bookshelf
bookshelfjs serviser
Last synced: about 1 year ago
JSON representation
Integrates bookshelf ORM with serviser
- Host: GitHub
- URL: https://github.com/lucid-services/serviser-bookshelf
- Owner: lucid-services
- License: gpl-3.0
- Created: 2019-02-07T09:04:38.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-11T17:24:54.000Z (over 7 years ago)
- Last Synced: 2025-02-14T22:23:59.789Z (over 1 year ago)
- Topics: bookshelfjs, serviser
- Language: JavaScript
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Bookshelf with `registry` & `virtuals` & `visibility` & `pagination` & `paranoia` & `eloquent` plugins.
```javascript
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`
```javascript
module.exports = function(bookshelf) {
return bookshelf.Model.extend({
tableName: 'user'
});
};
```