IndexedDB beginner. I have an objectStore with objects having fields f1, f2 and f3
. I want to search on this objectStore using values v1 and v2 using the following condition:
(f1==v1 OR f2==v1) AND (f3==v2)
I thought about using a compound index like objectStore.createIndex([f1, f2, f3])
but i realized this will not work because if I open cursor using query index.openCursor([v1, v1, v2])
, it will check the following condition:
f1==v1 AND f2==v1 AND f3==v3
So I decided to use two indices (f1, f3)
and (f2, f3)
. Get the objects from both queries and then eliminate the duplicates. But now I want to introduce pagination. If there was a single index, then pagination is simple, open cursor, advance it to the desired page number and then collect the pageSize number of objects. But now that I have two indices for this OR condition, how do I consistently implement pagination. My values are such that both f1 and f2 can match the v1 value.