Socket
Book a DemoInstallSign in
Socket

cah-base-model

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cah-base-model

Base model/collection for Bookshelf

1.0.0
latest
Source
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

cah-base-model

Intended Usage

Main application

'use strict';

// Set up knex and your bookshelf instance
var knex = require('knex');
var Bookshelf = require('bookshelf');
var db = knex({ client : 'pg', connection : 'postgres://127.0.0.1' });
Bookshelf.Instance = Bookshelf.initialize(db);
Bookshelf.Instance.plugin('registry');

require('cah-base-model')(Bookshelf.Instance);

require('my-user-module')(Bookshelf.Instance); // See below for definition

my-user-module.js

'use strict';

module.exports = function(bookshelf, inheritsFrom) {
  inheritsFrom = inheritsFrom || 'Base';

  bookshelf.model('User', bookshelf.model(inheritsFrom).extend({
    tableName : 'users',
    initialize : function() { console.log('Created a user model'); }
  }));

  bookshelf.collection('User', bookshelf.collection(inheritsFrom).extend({
    model : bookshelf.model('User')
  }));
}

FAQs

Package last updated on 30 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.