---
title: "IDBIndex | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Interface IDBIndex

**`IDBIndex`** interface of the IndexedDB API provides asynchronous access to an index in a database. An index is a kind of object store for looking up records in another object store, called the referenced object store. You use this interface to retrieve data.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex)

interface IDBIndex {  
    [keyPath](#keypath): string | string\[\];  
    [multiEntry](#multientry): boolean;  
    [name](#name): string;  
    [objectStore](#objectstore): [IDBObjectStore](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStore/);  
    [unique](#unique): boolean;  
    [count](#count-1)(query?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/)): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<number\>;  
    [get](#get-1)(query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/)): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<any\>;  
    [getAll](#getall-1)(  
        queryOrOptions?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null,  
        count?: number,  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<any\[\]\>;  
    [getAllKeys](#getallkeys-1)(  
        queryOrOptions?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null,  
        count?: number,  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/)\[\]\>;  
    [getKey](#getkey-1)(  
        query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/),  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | undefined\>;  
    [openCursor](#opencursor-1)(  
        query?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null,  
        direction?: [IDBCursorDirection](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBCursorDirection/),  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBCursorWithValue](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBCursorWithValue/) | null\>;  
    [openKeyCursor](#openkeycursor-1)(  
        query?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null,  
        direction?: [IDBCursorDirection](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBCursorDirection/),  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBCursor](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBCursor/) | null\>;  
}

##### Index

### Properties[](#properties)

[keyPath](#keypath) [multiEntry](#multientry) [name](#name) [objectStore](#objectstore) [unique](#unique)

### Methods[](#methods)

[count](#count) [get](#get) [getAll](#getall) [getAllKeys](#getallkeys) [getKey](#getkey) [openCursor](#opencursor) [openKeyCursor](#openkeycursor)

## Properties[](#properties-1)

### `Readonly`keyPath[](#keypath)

keyPath: string | string\[\]

The **`keyPath`** property of the IDBIndex interface returns the key path of the current index. If null, this index is not auto-populated.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/keyPath)

### `Readonly`multiEntry[](#multientry)

multiEntry: boolean

The **`multiEntry`** read-only property of the IDBIndex interface returns a boolean value that affects how the index behaves when the result of evaluating the index's key path yields an array.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/multiEntry)

### name[](#name)

name: string

The **`name`** property of the IDBIndex interface contains a string which names the index.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/name)

### `Readonly`objectStore[](#objectstore)

objectStore: [IDBObjectStore](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBObjectStore/)

The **`objectStore`** property of the IDBIndex interface returns the object store referenced by the current index.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/objectStore)

### `Readonly`unique[](#unique)

unique: boolean

The **`unique`** read-only property returns a boolean that states whether the index allows duplicate keys.

[MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/unique)

## Methods[](#methods-1)

### count[](#count)

-   count(query?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/)): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<number\>[](#count-1)
    
    The **`count()`** method of the IDBIndex interface returns an IDBRequest object, and in a separate thread, returns the number of records within a key range.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/count)
    
    #### Parameters
    
    -   `Optional`query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/)
    
    #### Returns [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<number\>
    

### get[](#get)

-   get(query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/)): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<any\>[](#get-1)
    
    The **`get()`** method of the IDBIndex interface returns an IDBRequest object, and, in a separate thread, finds either the value in the referenced object store that corresponds to the given key or the first corresponding value, if key is set to an IDBKeyRange.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/get)
    
    #### Parameters
    
    -   query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/)
    
    #### Returns [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<any\>
    

### getAll[](#getall)

-   getAll(  
        queryOrOptions?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null,  
        count?: number,  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<any\[\]\>[](#getall-1)
    
    The **`getAll()`** method of the IDBIndex interface retrieves all objects that are inside the index.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/getAll)
    
    #### Parameters
    
    -   `Optional`queryOrOptions: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null
    -   `Optional`count: number
    
    #### Returns [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<any\[\]\>
    

### getAllKeys[](#getallkeys)

-   getAllKeys(  
        queryOrOptions?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null,  
        count?: number,  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/)\[\]\>[](#getallkeys-1)
    
    The **`getAllKeys()`** method of the IDBIndex interface asynchronously retrieves the primary keys of all objects inside the index, setting them as the result of the request object.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/getAllKeys)
    
    #### Parameters
    
    -   `Optional`queryOrOptions: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null
    -   `Optional`count: number
    
    #### Returns [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/)\[\]\>
    

### getKey[](#getkey)

-   getKey(query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/)): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | undefined\>[](#getkey-1)
    
    The **`getKey()`** method of the IDBIndex interface returns an IDBRequest object, and, in a separate thread, finds either the primary key that corresponds to the given key in this index or the first corresponding primary key, if key is set to an IDBKeyRange.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/getKey)
    
    #### Parameters
    
    -   query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/)
    
    #### Returns [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | undefined\>
    

### openCursor[](#opencursor)

-   openCursor(  
        query?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null,  
        direction?: [IDBCursorDirection](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBCursorDirection/),  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBCursorWithValue](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBCursorWithValue/) | null\>[](#opencursor-1)
    
    The **`openCursor()`** method of the IDBIndex interface returns an IDBRequest object, and, in a separate thread, creates a cursor over the specified key range.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/openCursor)
    
    #### Parameters
    
    -   `Optional`query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null
    -   `Optional`direction: [IDBCursorDirection](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBCursorDirection/)
    
    #### Returns [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBCursorWithValue](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBCursorWithValue/) | null\>
    

### openKeyCursor[](#openkeycursor)

-   openKeyCursor(  
        query?: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null,  
        direction?: [IDBCursorDirection](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBCursorDirection/),  
    ): [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBCursor](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBCursor/) | null\>[](#openkeycursor-1)
    
    The **`openKeyCursor()`** method of the IDBIndex interface returns an IDBRequest object, and, in a separate thread, creates a cursor over the specified key range, as arranged by this index.
    
    [MDN Reference](https://developer.mozilla.org/docs/Web/API/IDBIndex/openKeyCursor)
    
    #### Parameters
    
    -   `Optional`query: [IDBValidKey](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBValidKey/) | [IDBKeyRange](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBKeyRange/) | null
    -   `Optional`direction: [IDBCursorDirection](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.IDBCursorDirection/)
    
    #### Returns [IDBRequest](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBRequest/)<[IDBCursor](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.IDBCursor/) | null\>
