How in Loopback I can extend model with custom function in mixin?
I have:
common/models/user.json
{
"name": "user",
"base": "User",
"idInjection": true,
"mixins": {
"ModelRest": {}
},
...
}
common/mixins/model-rest.js
module.exports = function (Model) {
Model.hello = function() {
console.log('hello!');
};
...
}
But in common/models/user.js
module.exports = function (User) {
User.hello();
...
}
I've got error:
TypeError: User.hello is not a function
What I'm doing wrong? Thanks for any help.
userin lower case. Here have an example: github.com/strongloop/loopback-example-mixins - jrltt