0
votes

i have a problem with Node JS loop-back include filter when i make a query .Every time its giving all records in response.but i want only those records that holds the sportid which i am passing in query filter.

 var request = {
     method: 'get',
     command: 'UserPersonalinfos',
     query: {
         filter: {
             "include": {
                 "relation": "UserRegistration",
                  "where": {
                      "sportid": data[0].id
                  }
             },
             limit:5
          }
     },
     headers: {
         access_token:userAccessToken.id,
     }
 };

if sportid exists then it should return object otherwise it should not, but in this case its returns all UserPersonalinfos records and adding UserRegistration object to UserPersonalinfos object

1
simply i want only those records in response those have sport id otherwise they should not be in response if record don't have sportid - pankaj malik

1 Answers

0
votes

As per https://stackoverflow.com/a/32933383/344022 there's nothing officially available yet. There is a fork of the loopback-connector by @DiogoDoreto that does attempt to provide it. I haven't tried it, but if you were to use it you would do the following in a filter:

  "where": {
    "UserRegistration": {
      "where": {
        "sportid": data[0].id
      }
    }
  }

The answer linked above also suggests some other ways of achieving what you want.