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

deleteByKey.md

41 lines613 Bytes

1---
2id: deleteByKey
3title: deleteByKey
4---
5​
6```ts
7function deleteByKey(objectStore, key): Promise<void>;
8```
9​
10Defined in: packages/db/src/indexed-db-wrapper.ts:456
11​
12Deletes an item by its key from an object store.
13​
14## Parameters
15​
16### objectStore
17​
18`IDBObjectStore`
19​
20The IDBObjectStore to delete from
21​
22### key
23​
24`IDBValidKey`
25​
26The key of the item to delete
27​
28## Returns
29​
30`Promise`\<`void`\>
31​
32A promise that resolves when the item is deleted
33​
34## Example
35​
36```typescript
37await executeTransaction(db, 'todos', 'readwrite', async (tx, stores) => {
38 await deleteByKey(stores.todos, 1)
39 console.log('Todo deleted')
40})
41```