Skip to content

Instantly share code, notes, and snippets.

@bjyoungblood
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjyoungblood/6c3c5cda125020331995 to your computer and use it in GitHub Desktop.
Save bjyoungblood/6c3c5cda125020331995 to your computer and use it in GitHub Desktop.
// This happens in the main application
'use strict';
var base = require('cah-base-model');
base.init(Bookshelf.PG);
var userModule = require('users-module');
userModule.initModels(base);
var User = userModule.models.User;
var myUser = new User.Model({ id : 1 }).fetch();
// This is its own module
'use strict';
var Model;
var Collection;
exports.init = function(bookshelf) {
Model = bookshelf.Model.extend(...);
Collection = bookshelf.Collection.extend(...);
};
exports.Model = Model;
exports.Collection = Collection;
// This is a model inside of a module
var Model;
var Collection;
exports.init = function(base) {
Model = base.Model.extend({}, {});
Collection = base.Model.extend({}, {});
};
exports.Model = Model;
exports.Collection = Collection;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment