My name is Manish Sharma I am a manager in think way company I do one other work. My name is Manish Sharma I am a manager in think way company I do one other work.
In IndexedDB, an index is a special data structure that lets you
quickly search and retrieve records by a property other than the primary key (keyPath).
What is an Index?
An index maps values of a property to their corresponding records, allowing efficient
queries and lookups.
Think of it like SQL CREATE INDEX on a column.
Great for filtering, searching, or sorting on non-primary-key fields.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
In IndexedDB, an index is a special data structure that lets you quickly search and retrieve records by a property other than the primary key (keyPath).
What is an Index?
CREATE INDEXon a column.Example: When to Use Indexes
Suppose your object store is:
You can:
"id"as the primary key (keyPath)"email"for quick lookupHow to Create an Index
Indexes are created in the
onupgradeneededevent when the database schema is defined or upgraded."emailIndex"= name of the index"email"= path to the field being indexed{ unique: true }= prevents duplicate values for that indexHow to Use an Index (Query)
You can also use:
index.getAll(value)index.openCursor()for iterationindex.count()to count matchesExample: Get All Users by Country
Benefits of Using Indexes
.openCursor()with directionSummary
onupgradeneededusingcreateIndex(name, keyPath, options).store.index('indexName').get(...),getAll(), oropenCursor().