crud icon indicating copy to clipboard operation
crud copied to clipboard

Filter with OR operator

Open hardikdgsa opened this issue 3 years ago • 1 comments
trafficstars

We have used this API for listing and filtering operations. it is working well. Now we want to have a filter with OR conditions, but as mentioned in the doc it does not work combined.

current URL is like this:- users?page=1&limit=10&sort[0]=createdAt,DESC&filter=id||in||462e640f-97ae-4b9e-9f8a-2f1f6f625d69&or[0]=user.firstName||$contL||Maira&or[1]=user.lastName||$contL||Maria&or[2]=user.email||$contL||Maria&or[3]=user.phone||$contL||Maria

In the above URL, it is not taking the filter in the result. The desired condition is: id=11 AND (firstName= ABC or Lastname = ABC or email= ABC). However, It is showing all the records matching the OR condition. If we don't add or condition, the filter is working fine. Do we have any option like we can use multiple OR condition with Filter?

hardikdgsa avatar Dec 20 '21 11:12 hardikdgsa

Hey men! i gout you XD use search

s: {"$and":[{"id":{"$in":"462e640f-97ae-4b9e-9f8a-2f1f6f625d69"}},{"$or":[{"user.firstName":{"$cont":"Maira"}},{"user.lastName":{"$cont":"Maria"}},{"user.email":{"$cont":"Maria"}},{"user.phone":{"$cont":"Maria"}}]}]}

fricred avatar Mar 09 '22 21:03 fricred