Add remote method to "base model" and extending in "extended models"

8 views
Skip to first unread message

Kevin Piacentini

unread,
Jun 24, 2016, 4:15:22 PM6/24/16
to LoopbackJS
Hi everybody,

I have an issue with my model and related methods. 

What I have: 

I currently have a Model named MyUser which is Based on User. Then, I have two other models (Player and Manager) based on MyUser. 

//Something like that:

_User
//builtin User Model
__MyUser
// Extends User // public: false
____Player
// Extends MyUser // public: true
____Manager //Extends MyUser // public: true


What I would like:

I would like to add a remote method to MyUser to be able to use it inside Manager and Player models. I tried many different ways but there is always an issue. 

First I tried to do like on the documentation (using setup() function): 

MyUser.setup = function(){
 
MyUser.greet = function(cb) {
   
//do something.
 
}
}

When I use setup(), only the MyUser model is shown on the Explorer (but is private!) and Manager and Player disappear (but they are public!).

I tried other versions like: 

MyUser.greet = function() {
//do something
}
//remote method stuff then...

But it never works... 

Someone could provide me a solution ? 

Thank you all :)

Regards,

Kevin.


Reply all
Reply to author
Forward
0 new messages