Search code examples
node.jsloopbackjsstrongloop

Overriding Relation Remote Method In Strongloop Loopback


I have a User model and a Follower model which has HasManyThrough relation with User for the follower and followee. How can I change the default __get__followers method parameters?


Solution

  • I figured out that I can juse add a new remote method the normal way.

    loopback.remoteMethod(
                UserModel.prototype.getFollows,
                {
                    description: 'Get the users who are followed by the user',
                    accepts: [
                        {arg: 'page', type: 'Number', http: {source: 'query'}, required: true}
                    ],
                    returns: {arg: 'data', type: 'object'},
                    http: {verb: 'get', path: '/follows'},
                    isStatic: false,
                }
        );