Web.IDB
- Package
- purescript-idb
- Repository
- philippedev101/purescript-idb
PureScript FFI bindings for IndexedDB via the idb library.
All operations run in Aff and work with any IndexedDB-compatible
environment (browsers, or Node.js with fake-indexeddb).
Transaction safety
IndexedDB transactions auto-commit when there are no pending requests
on the event loop. withWriteTransaction enforces this by accepting
an Effect callback (synchronous), preventing accidental awaits
that would close the transaction prematurely.
#IDBDatabase Source
data IDBDatabaseAn opaque handle to an open IndexedDB database.
#TxStore Source
data TxStoreAn opaque handle to an object store within a write transaction. Operations on TxStore are synchronous (Effect) to prevent the transaction from auto-committing between async operations.
#getAllKeys Source
getAllKeys :: IDBDatabase -> String -> Aff (Array String)Get all keys from a store (as strings).
#getAllEntries Source
getAllEntries :: IDBDatabase -> String -> Aff (Array (Tuple String Foreign))Get all key-value pairs from a store in a single readonly transaction. This is atomic: keys and values are guaranteed to be consistent.
#withWriteTransaction Source
withWriteTransaction :: IDBDatabase -> String -> (TxStore -> Effect Unit) -> Aff UnitExecute a batch of write operations in a single atomic transaction.
The callback receives a TxStore handle and must queue all operations
synchronously using txPut, txDelete, and txClear. The transaction
commits automatically when all queued operations complete.
The callback is Effect (not Aff) to prevent awaiting between
operations, which would cause the transaction to auto-commit.
#clearAndPutBatch Source
clearAndPutBatch :: IDBDatabase -> String -> Array (Tuple String Foreign) -> Aff UnitClear a store then put multiple key-value pairs, all in one atomic transaction.
#deleteBatch Source
deleteBatch :: IDBDatabase -> String -> Array String -> Aff UnitDelete multiple keys in a single atomic transaction.
- Modules
- Web.
IDB