javascript - Inheritance in Waterline ORM -
does waterline orm support inheritance? say, have model called businessdocument, , want create new model called salesorder extends businessdocument. so, salesorder should end having attributes of businessdocument plus new attributes. supported waterline?
it looks isn't supported out-of-the-box waterline. see github issue.
one of comments in above issue links sailscast video on youtube (here). in nutshell, video walks through using lodash merge child model base model, so:
basemodel.js
module.exports = { attributes : { name : 'string', age : 'integer' }, foo : function () {} } childmodel.js
var basemodel = require('/path/to/basemodel') , _ = require('lodash') module.exports = _.merge(basemodel, { attributes : { birthdate : 'date', ... } })
Comments
Post a Comment