I am using Loopback to create an API. The documentation, as a rule, is really good, but it really does not answer my question about the following: how can I extend (not replace) the built-in model?
The most promising information is obtained from this page - it determines how a class is based from another class through inheritance. This is useful, but not perfect - I would like to create relationships for user models from stock models, for example - A โroleโ must have many โPermissionsโ.
The page I mention also shows a Javascript file located in common/models/<modelName>.js , which indicates that you can "extend" the model based on the properties and parameters that you give it. The server never ends up in a file ... For example - I put the file in common/models/role.js with the following contents:
var properties = { exampleProperty: {type: String, required: true} }; var user = loopback.Model.extend('Role', properties); console.log('test');
Firstly, it does not get into the file at all (there is no console.log data). Secondly, obviously, because of the first point, it does not extend the model with the properties that I created.
Am I missing something obvious or is it just wrong?
source share