IndexedDB - Is KeyPath already an index?

Quick question.

When you create IndexedDB and specify a specific one keyPath

, do you still need to create and index the same key?

I would guess which keyPath

is the index itself, but I don't know and haven't found any information on this.

Edit: Okay, to clarify what I mean: Are you getting the performance advantage on the index using keyPath?

+3


source to share


1 answer


This doesn't technically create an index, but it's basically the same thing. Every object in the database is associated with a key. If you set a key path, then they will match all key paths. Then you can query for that key (for example IDBObjectStore.get

), no index is needed.

Indexes are only included if you want to efficiently query your database for something other than a key.



So the answer to your question is no, you don't need to create an index with the same key.

+2


source







All Articles