loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Rest API equivalent for named scope in model

Open sant0shg opened this issue 9 years ago • 1 comments

In the documentation for named scope in loopback 3, , the named scope can be defined in boot script as

User.scope('top10Vips', {where: {vip: true}, limit: 10});

Which can be used as User.top10Vips(function(err, vips) { });

But if I want it to be called by sending the scope name (top10Vips) in the GET query, it does not apply the scope filter.

I tried many variations of this query

http://localhost:8090/api/model/modelname?filter={"order":"timestamp DESC","limit":20,"scope":"top10Vips"} I get the results without the top10Vips filter applied.

If I add the include filter, I get the error Relation "scope" is not defined for modelname

http://localhost:8090/api/model/Actions?filter={"order":"timestamp DESC","limit":20,"include":{"scope":"top10Vips"}

So what is the rest equivalent of User.top10Vips(function(err, vips) { });

sant0shg avatar Aug 23 '17 05:08 sant0shg

Posted to google group

sant0shg avatar Aug 23 '17 05:08 sant0shg