javascript - Using an OR condition in TaffyDB with "lte" and "gte" -


i have data in taffy db this. data points can blank:

{"first_name":"sam", "last_name": "andrew", "age":26 ... } {"first_name":"jane", "last_name": "doe", "age": 19 ... }  {"first_name":"john", "last_name": "deer", "age":51 ... } . . . 

if need rows first name either "john" or "jane", age between 40 , 60, query be:

{     "name":["john","jane"],      "age":{"lte":60,"gte":40} } 

now if add condition age can less 20 well, unable write query that.

i have tried not work:

{     "name":["john","jane"],      "age":[{"lte":60,"gte":40},{"lte":20}] } 

any appreciated.

it helps break down age-related or statement , name-and-age and statement.

you want name condition and age condition (which contains own or)

a standard and statement written (in pseudocode) as:

db({name_condition, age_condition}) 

but can written as

db({name_condition},{age_condition}) 

this second notation needed accomplish compound condition you're looking for.

because entire age condition 1 simple or statement, you'd put in array.

[   {age:{"lte":20}},   {age:{"gte":40,"lte":60}} ] 

either age less than 20 or age between 40 , 60.

the name condition straightforward

{first_name:["john","jane"]} 

put 2 objects and statement this:

db({first_name:["john","jane"]},[{age:{"lte":20}},{age:{"gte":40,"lte":60}}]) 

Comments