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

clear.md

35 lines605 Bytes

1---
2id: clear
3title: clear
4---
5​
6```ts
7function clear(objectStore): Promise<void>;
8```
9​
10Defined in: [packages/db/src/indexed-db-wrapper.ts:531](https://github.com/TanStack/db/blob/main/packages/db/src/indexed-db-wrapper.ts#L531)
11​
12Removes all items from an object store.
13​
14## Parameters
15​
16### objectStore
17​
18`IDBObjectStore`
19​
20The IDBObjectStore to clear
21​
22## Returns
23​
24`Promise`\<`void`\>
25​
26A promise that resolves when all items are removed
27​
28## Example
29​
30```typescript
31await executeTransaction(db, 'todos', 'readwrite', async (tx, stores) => {
32 await clear(stores.todos)
33 console.log('All todos cleared')
34})
35```