Inheritance at Waterline ORM

Does OHP Waterline ORM support inheritance? Let's say I have a model called BusinessDocument, and I want to create a new model called SalesOrder, which extends BusinessDocument. Therefore, it SalesOrdershould have all the attributes BusinessDocumentplus some new attributes. Is it supported by Waterline?

+4
source share
1 answer

It seems that it is not supported due to the box from Waterline. See the GitHub issue .

One of the comments in the above issue is also related to the YouTube password video ( here ). In a nutshell, the video is viewed using lodash to merge a child model with a base model, for example:

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',
    ...
  }
})
+1
source

Source: https://habr.com/ru/post/1609703/


All Articles