我可以在不同的.js文件上分离模型自定义逻辑,例如:
/common/models/
... MyMode.js
... MyModel.hooks.js
... MyModel.validations.js
... MyModel.json
答案 0 :(得分:0)
我知道了;
需要其他文件并在model.js主文件中调用它们
let validation = require('./sample.validations');
let model = require('./sample.model');
//sample.js
module.exports = function (Sample) {
model(Sample);
validation(Sample);
};
//sample.model.js
module.exports = function (Sample) {
console.log('log from model');
};
//Sample.validations.js
module.exports = function (Sample) {
console.log('log from validations');
};