Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

getAllKeys.md

37 lines752 Bytes

1---
2id: getAllKeys
3title: getAllKeys
4---
5​
6```ts
7function getAllKeys(objectStore): Promise<IDBValidKey[]>;
8```
9​
10Defined in: [packages/db/src/indexed-db-wrapper.ts:396](https://github.com/TanStack/db/blob/main/packages/db/src/indexed-db-wrapper.ts#L396)
11​
12Retrieves all keys from an object store.
13​
14Uses the native `getAllKeys()` method for efficient bulk key retrieval.
15​
16## Parameters
17​
18### objectStore
19​
20`IDBObjectStore`
21​
22The IDBObjectStore to read keys from
23​
24## Returns
25​
26`Promise`\<`IDBValidKey`[]\>
27​
28A promise that resolves to an array of all keys in the store
29​
30## Example
31​
32```typescript
33await executeTransaction(db, 'todos', 'readonly', async (tx, stores) => {
34 const allKeys = await getAllKeys(stores.todos)
35 console.log('All keys:', allKeys)
36})
37```