Create an Index for the Object Store
Learn to create an index for the object store.
We'll cover the following...
The createIndex()
method
To create an index in IndexedDB, we use the createIndex()
method of the IDBObjectStore
interface. The createIndex()
method can be called only inside the onupgradeneeded
event handler.
Syntax
createIndex(name, keyPath)createIndex(name, keyPath, options)
Syntax for the createIndex() method
The createIndex()
method takes three arguments:
name
: The name of the new index. It is used to identify the index when we need to query it or perform other operations. The name must be unique within a ...