mirror of
https://github.com/ilyakooo0/purescript-indexedDB.git
synced 2024-09-11 06:55:48 +03:00
2.2 KiB
2.2 KiB
PureScript IndexedDB
![Build Status](https://travis-ci.org/truqu/purescript-indexeddb.svg?branch=master)
This package offers complete bindings and type-safety upon the IndexedDB API.
Overview
main :: Eff (idb :: IDB, exception :: EXCEPTION, console :: CONSOLE) Unit
main = launchAff' do
db <- IDBFactory.open "db" Nothing { onBlocked : Nothing
, onUpgradeNeeded : Just onUpgradeNeeded
}
tx <- IDBDatabase.transaction db ["store"] ReadOnly
store <- IDBTransaction.objectStore tx "store"
(val :: Maybe String) <- IDBObjectStore.get store (IDBKeyRange.only 1)
log $ maybe "not found" id val
onUpgradeNeeded :: forall e. Database -> Transaction -> Eff (idb :: IDB, exception :: EXCEPTION | e) Unit
onUpgradeNeeded db _ = launchAff' do
store <- IDBDatabase.createObjectStore db "store" IDBObjectStore.defaultParameters
_ <- IDBObjectStore.add store "patate" (Just 1)
_ <- IDBObjectStore.add store { property: 42 } (Just 2)
_ <- IDBObjectStore.createIndex store "index" ["property"] IDBIndex.defaultParameters
pure unit
Changelog
- Release incoming
TODO
- Add support for
index.getAll
method - Complete the specifications with the official tests list provided by W3C
Documentation
Module documentation is published on Pursuit.
Testing
Tested in the cloud on multiple browsers and operating systems thanks to BrowserStack
IE / Edge | Chrome | Firefox | Safari | Opera | Android | iOS Safari |
---|---|---|---|---|---|---|
- | >= 57 | >= 51 | - | >= 46 | - | - |