DB Docs
API Reference
- Core API Reference
- Collection
- createCollection
- liveQueryCollectionOptions
- createLiveQueryCollection
- createOptimisticAction
- createTransaction
- Electric DB Collection
- electricCollectionOptions
- Query DB Collection
- queryCollectionOptions
- RxDB DB Collection
- rxdbCollectionOptions
- PowerSync Collection
- powerSyncCollectionOptions
- createIndexedDB
- indexedDBCollectionOptions
- React Hooks
- useLiveQuery
AI/LLM: This documentation page is available in plain markdown format at/db/latest/docs/reference/functions/deleteByKey.md
deleteByKey
ts
function deleteByKey(objectStore, key): Promise<void>;Defined in: packages/db/src/indexed-db-wrapper.ts:500
Deletes an item by its key from an object store.
Parameters#
objectStore#
IDBObjectStore
The IDBObjectStore to delete from
key#
IDBValidKey
The key of the item to delete
Returns#
Promise<void>
A promise that resolves when the item is deleted
Example#
ts
await executeTransaction(db, 'todos', 'readwrite', async (tx, stores) => {
await deleteByKey(stores.todos, 1)
console.log('Todo deleted')
})