-1

I've questions about working with build-in models in Loopback. I need to extend my built-in model - User with custom relations.

// Extend properties
var properties = {

};

// Extend options
var options = {
    relations: {
        rooms: {
            type: "hasMany",
            model: "Room",
            foreignKey: ""
        }
    }
};

// Call method
loopback.Model.extend('User', properties, options);

But it isn't work in my case, after restarting server model has't new rest-method and new properties.

Maybe I do something wrong, but maybe now communite has new solution for it?

Daniel Higueras
  • 2,404
  • 22
  • 34
Borisov Semen
  • 448
  • 5
  • 8
  • if this or any answer has solved your question please consider [accepting it](http://meta.stackexchange.com/q/5234/179419) by clicking the check-mark. This indicates to the wider community that you've found a solution and gives some reputation to both the answerer and yourself. There is no obligation to do this. – Overdrivr Feb 14 '16 at 09:57

1 Answers1

-2

You cannot modify built-in models.

Instead create a MyUser model that extends User, and modify MyUser, add it relations, methods etc.

You can hide User later on if you only want to see MyUser in the API explorer.

Overdrivr
  • 6,296
  • 5
  • 44
  • 70