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

getAll.md

45 lines788 Bytes

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