underscore-query icon indicating copy to clipboard operation
underscore-query copied to clipboard

Is there a $toBool capability?

Open thardy opened this issue 4 years ago • 1 comments

I have a lot of queries that need to filter based on the truthiness of many state properties. What would be the best way to handle those conditions with underscore-query?

thardy avatar Sep 16 '21 00:09 thardy

The best I've come up with is the following...

For a condition where any of the answers is truthy...

$or: [ "formAnswers.answerOne": {$nin: [0, null, false, ""]}, "formAnswers.answerTwo": {$nin: [0, null, false, ""]}, "formAnswers.answerThree": {$nin: [0, null, false, ""]}, ]

It seems like there should be a simpler way to do this.

thardy avatar Sep 16 '21 00:09 thardy