Reputation: 1639
We're getting unexpected and inconsistent results when using Loopback's count end-point. Using filter[where] always returns the total number of rows in the table, ignoring any filter. For example, the following call always returns a value of 9 which is not correct (given the data below):
/api/class/count?filter[where][companyrowid]=1
Class Table Data (MySQL)
rowid description companyrowid
3367 test1 0
3366 test2 0
3364 Asia Division 1
3365 Australia Division 1
3362 Canada Division 1
3363 Europe Division 1
3359 US East Division 1
3361 US Midwest Division 1
3360 US West Division 1
Strangely, using 'where[companyid]=1' returns the correct value of 7. Close inspection of the http request object shows that filter[where][...] and where[..] filters are actually stored separately and yield different results:
/api/class/count?filter[where][companyrowid]=1
/api/class/count?where[companyrowid]=1
The biggest issue is the filter[where] ignoring the filter.
Upvotes: 0
Views: 862
Reputation: 1107
count() method only takes the where clause instead of the filter. So your REST API should be like this
/api/class/count?[where][companyrowid]=1
Upvotes: 3