The user can filter data on list endpoint, not depending to create another endpoint to filter or include data. The user can do something like this:
/categories?user=victor&include=product,owner
So, the include will do a subquery including the fields that are in parent model and the filter will filter the response (also in the query) bringing only the data that matches with relation key-value on the filter (in the example case, all users that have user matching with "victor").
To include filters or include on req (request) object the route must have a Filter and an Include Middleware (as below,).
app.VERB('/', [RetrieveFilters, RetrieveIncludes CheckToken], (req,res) => this.controller.METHOD(req,res));
The user can filter data on list endpoint, not depending to create another endpoint to filter or include data. The user can do something like this:
/categories?user=victor&include=product,ownerSo, the include will do a subquery including the fields that are in parent model and the filter will filter the response (also in the query) bringing only the data that matches with relation key-value on the filter (in the example case, all users that have user matching with "victor").
To include filters or include on req (request) object the route must have a Filter and an Include Middleware (as below,).
app.VERB('/', [RetrieveFilters, RetrieveIncludes CheckToken], (req,res) => this.controller.METHOD(req,res));