db.js icon indicating copy to clipboard operation
db.js copied to clipboard

Does db.js support the creation of multi-segment indexes?

Open jlddodger opened this issue 12 years ago • 3 comments

The algorithm defined in the IndexedDB specification for evaluating key paths has this first step:

"

  1. If keyPath is a sequence<DOMString>, then let result be newly constructed empty Array. For each item in the keyPath sequence, perform the following substeps:
1. Evaluate the steps for extracting a key from a value using a key path using the item from the keyPath sequence as keyPath and value as value.
2. If the result of the previous step was not a valid key, then abort the overall algorithm and no value is returned.
3. Add the result of the first sub-step to end of the result array.

Return result as result of this algorithm and perform no additional steps. "

The above leads me to believe that it should be possible to construct multi-segment indexes like "keyPath: [lastName, firstName]". Your 10/2/2012 blog post seems to imply that this is not possible:

" Indexes and Queries in db.js [...] The indexes in IndexedDB are only single key indexes so there are times that you're going to be trying to create a query in a way that can't be done, say you want to query against two properties. Well that's not going to be possible to do with an index and this is where db.js can help. "

Is it possible to construct these multi-segment indexes in IndexedDB and is it possible via db.js?

jlddodger avatar Oct 16 '13 05:10 jlddodger

Presently no, there's no way which you can perform index-level queries using multiple indexes

aaronpowell avatar Oct 16 '13 07:10 aaronpowell

Is it still the case that these indexes cannot be done? It seems like one should be able to supply an array for keyPath (also covered in #46, #72).

brettz9 avatar Mar 27 '16 19:03 brettz9

Compound queries are now demoed in the README and in the indexes test. So I believe this issue can now be closed.

brettz9 avatar Apr 11 '16 16:04 brettz9