Package

purescript-idb

Repository
philippedev101/purescript-idb
License
Apache-2.0
Uploaded by
pacchettibotti
Published on
2026-03-06T16:52:14Z

PureScript FFI bindings for the idb library, providing a simple Aff-based API for IndexedDB.

API

open    :: String -> Int -> Array String -> Aff IDBDatabase
get     :: IDBDatabase -> String -> String -> Aff (Maybe Foreign)
getAll  :: IDBDatabase -> String -> Aff (Array Foreign)
put     :: IDBDatabase -> String -> String -> Foreign -> Aff Unit
delete  :: IDBDatabase -> String -> String -> Aff Unit
clear   :: IDBDatabase -> String -> Aff Unit

Usage

import Web.IDB as IDB
import Foreign (unsafeToForeign, unsafeFromForeign)

main :: Effect Unit
main = launchAff_ do
  db <- IDB.open "my-db" 1 ["items"]
  IDB.put db "items" "key1" (unsafeToForeign "hello")
  result <- IDB.get db "items" "key1"
  -- result :: Maybe Foreign

Setup

Requires PureScript (purs) on PATH (e.g. via nix-shell).

bun install
bunx spago build
bunx spago test

Testing

Tests use fake-indexeddb to provide an in-memory IndexedDB implementation in Node.js.

bunx spago test
Modules
Web.IDB
Dependencies