Alparslan Yılmaz
Alparslan Yılmaz

Reputation: 105

Loopback scope filter does not work in find query

I am trying to load 5 data included to main model. But instead of this, I got whole relation data and so on. The problem caused by include filter

const person = await this.PersonModel.findOne({
  "where": {
    "id": personId,
    "userId": userId,
  },
  "include": {
    "relation": "projects",
    "scope": {
      "order": "createdDate DESC",
      "skip": 0,
      "limit": 5
    }
  }
});

When I use order parameter alone, it works. But when I add skip and limit parameters, order parameter doesn't work either.

So what am I doing wrong?

Upvotes: 1

Views: 258

Answers (1)

Alparslan Yılmaz
Alparslan Yılmaz

Reputation: 105

I found the solution. Loopback3 does not support second level filtering. So this means you are not able to run filter query at included data. You have to create function/endpoint in the end.

Upvotes: 1

Related Questions