简体   繁体   中英

Geddy model / controller inheritance

Is it possible to make inheritnace with geddy model? I'm thinking like this:

model/base.js

module.exports = function(query, options){
 self = this;
 // some custom codes goes here that need to be use on some models
}

model/model1.js

util = require('util');
Base = require('./base');

Model1 = function(){
 this.defineProperties({ .... });

 ... and more
}
util.inherits(Model1, Base);
exports.Model1 = Model1;

and same with the controllers like baseFrontend.js for the frontend and baseBackend.js for the backend controllers.

Thanks in advance guys.

Since this is JavaScript, I don't think the term "inheritance" really applies.

It is certainly okay to mix-in shared methods into your models and controllers.

geddy.mixin(Model1, Base);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM