Dexie.js
Dexie.js copied to clipboard
AnyOf on multiple columns
I know it's possible to use AnyOf on compound indexes like so:
db.people
.where('[firstName+lastName]').anyOf([
["Foo", "Bar"],
["Baz", "Qux"]
]).toArray();
And i know this same approach works on compound indexes with more then 2 indexes, but is there any way to avoid sending all permutations of the indata?
For instance, if i'm interested in index1 IN [a,b] and index2 IN [c,d] and index3 IN [e,f]
, is there a way to avoid doing
where('[index1+index2+index3]').anyOf([[a,c,e],[a,d,e],[a,c,f],[a,d,f],[b,c,e],[b,d,e],[b,c,f,],[b,d,f]])
And do something akin to
where('[index1+index2+index3]').anyOf([a,b],[c,d][e,f])
instead?
Because the amount of permutations we need to send with multiple variables balloons out of control quite fast in certain use cases.
I see the use case. Such algorithm could be possible (but currently not part of dexie's toolkit right now). This kind of query can also be achieved by indexing each field individually, query each index with Collection.primaryKeys() and then load the objects from the intersection between the primary key results. There's an updated a sample on how to do that in the docs of Collection.primaryKeys().