executor: remove `Base` arg from model function
Simplify the contract for functions exported by `models/*.js` files by removing the second argument `Base`. The base class can be accessed using `ModelCtor.base`. An updated example of a model js file: ```js module.exports = function(Customer) { Customer.setup = function() { Customer.base.setup.apply(this, arguments); // etc. }; }; ```
This commit is contained in:
parent
b5989e907e
commit
c4b09c6b7a
|
@ -156,8 +156,7 @@ function defineModels(app, instructions) {
|
||||||
var code = require(data.sourceFile);
|
var code = require(data.sourceFile);
|
||||||
if (typeof code === 'function') {
|
if (typeof code === 'function') {
|
||||||
debug('Customizing model %s', name);
|
debug('Customizing model %s', name);
|
||||||
// NOTE model.super_ is set by Node's util.inherits
|
code(model);
|
||||||
code(model, model.super_);
|
|
||||||
} else {
|
} else {
|
||||||
debug('Skipping model file %s - `module.exports` is not a function',
|
debug('Skipping model file %s - `module.exports` is not a function',
|
||||||
data.sourceFile);
|
data.sourceFile);
|
||||||
|
|
|
@ -56,9 +56,9 @@ describe('executor', function() {
|
||||||
|
|
||||||
it('defines and customizes models', function() {
|
it('defines and customizes models', function() {
|
||||||
appdir.writeFileSync('models/Customer.js', 'module.exports = ' +
|
appdir.writeFileSync('models/Customer.js', 'module.exports = ' +
|
||||||
function(Customer, Base) {
|
function(Customer) {
|
||||||
Customer.settings._customized = 'Customer';
|
Customer.settings._customized = 'Customer';
|
||||||
Base.settings._customized = 'Base';
|
Customer.base.settings._customized = 'Base';
|
||||||
}.toString());
|
}.toString());
|
||||||
|
|
||||||
boot.execute(app, someInstructions({
|
boot.execute(app, someInstructions({
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
module.exports = function(Customer, Base) {
|
module.exports = function(Customer) {
|
||||||
Customer.settings._customized = 'Customer';
|
Customer.settings._customized = 'Customer';
|
||||||
Base.settings._customized = 'Base';
|
Customer.base.settings._customized = 'Base';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue