Search code examples
node.jsrestloopbackjsstrongloop

LoopBack filter "where and " return wrong/same result in any value


This is what in loopback docs said about using and operators

rest: ?filter[where][and][0][title]=My%20Post&filter[where][and][1][content]=Hello

I tried:

count?filter{"where":[{"and"}[{"user_id":"5a6840ddb2b58b07cca3c680"},{"post_id":"4444"}]} //post_id:4444 is not exit

and

count?filter[where][and][0][user_id]="5a6840ddb2b58b07cca3c680"&filter[where][and][1][post_id]="5a6253bdcf975122dcf11dd8"

and many other forms but the result is count: 12 but should return 0 in 4444 or any wrong post_id. also, post_id and user_id are relational Objectid.


Solution

  • Remove the filter and just use a where. (Thanks to Raymond Feng for helping me with this.)