简体   繁体   English

吉迪模型/控制器继承

[英]Geddy model / controller inheritance

Is it possible to make inheritnace with geddy model? 是否可以使用geddy模型进行继承? I'm thinking like this: 我在想这样的:

model/base.js 型号/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 型号/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. 并与诸如baseFrontend.js和针对后端控制器的baseBackend.js之类的控制器相同。

Thanks in advance guys. 在此先感谢大家。

Since this is JavaScript, I don't think the term "inheritance" really applies. 由于这是JavaScript,因此我认为“继承”一词并不适用。

It is certainly okay to mix-in shared methods into your models and controllers. 将共享方法混入模型和控制器中当然可以。

geddy.mixin(Model1, Base);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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