Search code examples
loopbackjs

Loopback: Use multiple include filters in query


I am trying to include multiple related models in a query:

/distributors?filter[include][depots]=drivers&filter[include]=delivery_times

However this seems to duplicate the drivers for each distributor and doesn't return any delivery_time.

This

/distributors?filter[include]=delivery_times

and this:

/distributors?filter[include][depots]=drivers

seems to work fine though.

What could be the issue here?


Solution

  • Multiple include should be done like this on REST:

    /distributors?filter[include][0][depots]=drivers&filter[include][1]=delivery_times