git.iko.soy/purescript-indexed-DB
on master help sign in
Use IDBKey type-class to make add & put more friendly
commita5170f38935354e8aaaff1aa733a77183bddd946 authorKtorZ <matthias.benkort@gmail.com> dateFri 30 Jun 2017, 18:39 (9 years ago) parent376d435
1 file changed+6−6
src/Database/IndexedDB/IDBObjectStore.purs+6−6
src/Database/IndexedDB/IDBObjectStore.purs+6−6
@@ -11,7 +11,7 @@ module Database.IndexedDB.IDBObjectStore
1111 , defaultParameters
1212 ) where
1313
14−import Prelude (Unit, ($), (<$>))
14+import Prelude (Unit, ($), (<$>), (>>>))
1515
1616import Control.Monad.Aff (Aff)
1717import Control.Monad.Eff (Eff)
@@ -24,20 +24,20 @@ import Data.Nullable (Nullable, toNullable)
2424
2525import Database.IndexedDB.Core (IDB, Index, KeyRange, KeyPath, ObjectStore, Transaction)
2626import Database.IndexedDB.IDBIndex.Internal (class IDBIndex, IDBIndexParameters, count, get, getAllKeys, getKey, openCursor, openKeyCursor)
27−import Database.IndexedDB.IDBKey.Internal (Key(Key), extractForeign)
27+import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key(Key), extractForeign, toKey)
2828
2929
3030--------------------
3131-- INTERFACES
3232--
3333class IDBObjectStore store where
34− add :: forall value e. store -> value -> Maybe Key -> Aff (idb :: IDB | e) Key
34+ add :: forall v k e. (IDBKey k) => store -> v -> Maybe k -> Aff (idb :: IDB | e) Key
3535 clear :: forall e. store -> Aff (idb :: IDB | e) Unit
3636 createIndex :: forall e. store -> IndexName -> KeyPath -> IDBIndexParameters -> Eff (idb :: IDB, exception :: EXCEPTION | e) Index
3737 delete :: forall e. store -> KeyRange -> Aff (idb :: IDB | e) Unit
3838 deleteIndex :: forall e. store -> IndexName -> Eff (idb :: IDB, exception :: EXCEPTION | e) Unit
3939 index :: forall e. store -> IndexName -> Eff (idb :: IDB, exception :: EXCEPTION | e) Index
40− put :: forall value e. store -> value -> Maybe Key -> Aff (idb :: IDB | e) Key
40+ put :: forall v k e. (IDBKey k) => store -> v -> Maybe k -> Aff (idb :: IDB | e) Key
4141
4242
4343type IndexName = String
@@ -82,7 +82,7 @@ transaction =
8282--
8383instance idbObjectStoreObjectStore :: IDBObjectStore ObjectStore where
8484 add store value key =
85− Key <$> Fn.runFn3 _add store value (toNullable $ extractForeign <$> key)
85+ Key <$> Fn.runFn3 _add store value (toNullable $ (toKey >>> extractForeign) <$> key)
8686
8787 clear =
8888 _clear
@@ -100,7 +100,7 @@ instance idbObjectStoreObjectStore :: IDBObjectStore ObjectStore where
100100 Fn.runFn2 _index store name'
101101
102102 put store value key =
103− Key <$> Fn.runFn3 _put store value (toNullable $ extractForeign <$> key)
103+ Key <$> Fn.runFn3 _put store value (toNullable $ (toKey >>> extractForeign) <$> key)
104104
105105
106106defaultParameters :: IDBObjectStoreParameters