git.iko.soy/purescript-indexed-DB
on master help sign in
make Key a complete opaque type
commit24fa04adcb50017818a8bc102b28bb8a87c7df6c authorKtorZ <matthias.benkort@gmail.com> dateFri 28 Jul 2017, 11:12 (9 years ago) parent3b53339
6 files changed+101−107
src/Database/IndexedDB/IDBCursor.purs+20−20 src/Database/IndexedDB/IDBIndex.purs+11−11 src/Database/IndexedDB/IDBKey/Internal.purs+6−8 src/Database/IndexedDB/IDBKeyRange.purs+21−25 src/Database/IndexedDB/IDBObjectStore.purs+9−9 test/Main.purs+34−34
src/Database/IndexedDB/IDBCursor.purs+20−20
@@ -27,7 +27,7 @@ import Data.Nullable (Nullable, toNullable)
2727import Data.String.Read (read)
2828
2929import Database.IndexedDB.Core
30−import Database.IndexedDB.IDBKey.Internal (class IDBKey, toKey)
30+import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, toKey, unsafeFromKey)
3131import Database.IndexedDB.IDBKey.Internal as IDBKey
3232
3333
@@ -52,7 +52,7 @@ continue
5252 -> Maybe k
5353 -> Aff (idb :: IDB | e) Unit
5454continue c mk =
55− Fn.runFn2 _continue c (toNullable $ map (toKey >>> IDBKey.toForeign) mk)
55+ Fn.runFn2 _continue c (toNullable $ map (toKey >>> unsafeFromKey) mk)
5656
5757
5858-- | Advances the cursor to the next record in range matching or after key and primaryKey. Throws an "InvalidAccessError" DOMException if the source is not an index.
@@ -63,7 +63,7 @@ continuePrimaryKey
6363 -> k
6464 -> Aff (idb :: IDB | e) Unit
6565continuePrimaryKey c k1 k2 =
66− Fn.runFn3 _continuePrimaryKey c (IDBKey.toForeign $ toKey k1) (IDBKey.toForeign $ toKey k2)
66+ Fn.runFn3 _continuePrimaryKey c (unsafeFromKey $ toKey k1) (unsafeFromKey $ toKey k2)
6767
6868
6969-- | Delete the record pointed at by the cursor with a new value.
@@ -80,12 +80,12 @@ delete =
8080-- | Throws a "DataError" DOMException if the effective object store uses
8181-- | in-line keys and the key would have changed.
8282update
83− :: forall val e cursor key. (IDBCursor cursor) => (IDBKey key)
83+ :: forall val e cursor. (IDBCursor cursor)
8484 => cursor
8585 -> val
86− -> Aff (idb :: IDB | e) key
86+ -> Aff (idb :: IDB | e) Key
8787update c =
88− toForeign >>> Fn.runFn2 _update c
88+ toForeign >>> Fn.runFn2 _update c >>> map toKey
8989
9090
9191--------------------
@@ -104,21 +104,21 @@ direction =
104104-- | Returns the key of the cursor. Throws a "InvalidStateError" DOMException
105105-- | if the cursor is advancing or is finished.
106106key
107− :: forall e cursor key. (IDBConcreteCursor cursor) => (IDBKey key)
107+ :: forall e cursor. (IDBConcreteCursor cursor)
108108 => cursor
109− -> Aff (idb :: IDB | e) key
109+ -> Aff (idb :: IDB | e) Key
110110key =
111− _key
111+ _key >>> map toKey
112112
113113
114114-- | Returns the effective key of the cursor. Throws a "InvalidStateError" DOMException
115115-- | if the cursor is advancing or is finished.
116116primaryKey
117− :: forall e cursor key. (IDBConcreteCursor cursor) => (IDBKey key)
117+ :: forall e cursor. (IDBConcreteCursor cursor)
118118 => cursor
119− -> Aff (idb :: IDB | e) key
119+ -> Aff (idb :: IDB | e) Key
120120primaryKey =
121− _primaryKey
121+ _primaryKey >>> map toKey
122122
123123
124124-- | Returns the IDBObjectStore or IDBIndex the cursor was opened from.
@@ -169,15 +169,15 @@ foreign import _direction
169169
170170
171171foreign import _key
172− :: forall cursor e key. (IDBKey key)
173− => cursor
174− -> Aff (idb :: IDB | e) key
172+ :: forall cursor e
173+ . cursor
174+ -> Aff (idb :: IDB | e) Key
175175
176176
177177foreign import _primaryKey
178− :: forall cursor e key. (IDBKey key)
179− => cursor
180− -> Aff (idb :: IDB | e) key
178+ :: forall cursor e
179+ . cursor
180+ -> Aff (idb :: IDB | e) Key
181181
182182
183183foreign import _source
@@ -186,8 +186,8 @@ foreign import _source
186186
187187
188188foreign import _update
189− :: forall cursor e key. (IDBKey key)
190− => Fn2 cursor Foreign (Aff (idb :: IDB | e) key)
189+ :: forall cursor e
190+ . Fn2 cursor Foreign (Aff (idb :: IDB | e) Foreign)
191191
192192
193193foreign import _value
src/Database/IndexedDB/IDBIndex.purs+11−11
@@ -32,7 +32,7 @@ import Data.Maybe (Maybe)
3232import Data.Nullable (Nullable, toMaybe, toNullable)
3333
3434import Database.IndexedDB.Core
35−import Database.IndexedDB.IDBKey.Internal (class IDBKey, toKey)
35+import Database.IndexedDB.IDBKey.Internal (Key, toKey)
3636
3737
3838--------------------
@@ -77,23 +77,23 @@ get index range =
7777-- | Retrieves the keys of records matching the given key range in query
7878-- | (up to the number given if given).
7979getAllKeys
80− :: forall e index key. (IDBIndex index) => (IDBKey key)
80+ :: forall e index. (IDBIndex index)
8181 => index
8282 -> Maybe KeyRange
8383 -> Maybe Int
84− -> Aff (idb :: IDB | e) (Array key)
84+ -> Aff (idb :: IDB | e) (Array Key)
8585getAllKeys index range n =
86− Fn.runFn3 _getAllKeys index (toNullable range) (toNullable n)
86+ map toKey <$> Fn.runFn3 _getAllKeys index (toNullable range) (toNullable n)
8787
8888
8989-- | Retrieves the key of the first record matching the given key or key range in query.
9090getKey
91− :: forall e index key. (IDBIndex index) => (IDBKey key)
91+ :: forall e index. (IDBIndex index)
9292 => index
9393 -> KeyRange
94− -> Aff (idb :: IDB | e) (Maybe key)
94+ -> Aff (idb :: IDB | e) (Maybe Key)
9595getKey index range =
96− toMaybe <$> Fn.runFn2 _getKey index range
96+ (toMaybe >>> map toKey) <$> Fn.runFn2 _getKey index range
9797
9898
9999-- | Opens a ValueCursor over the records matching query, ordered by direction.
@@ -204,13 +204,13 @@ foreign import _get
204204
205205
206206foreign import _getAllKeys
207− :: forall index e k. (IDBKey k)
208− => Fn3 index (Nullable KeyRange) (Nullable Int) (Aff (idb :: IDB | e) (Array k))
207+ :: forall index e
208+ . Fn3 index (Nullable KeyRange) (Nullable Int) (Aff (idb :: IDB | e) (Array Foreign))
209209
210210
211211foreign import _getKey
212− :: forall index e k. (IDBKey k)
213− => Fn2 index KeyRange (Aff (idb :: IDB | e) (Nullable k))
212+ :: forall index e
213+ . Fn2 index KeyRange (Aff (idb :: IDB | e) (Nullable Foreign))
214214
215215
216216foreign import _openCursor
src/Database/IndexedDB/IDBKey/Internal.purs+6−8
@@ -5,7 +5,6 @@ module Database.IndexedDB.IDBKey.Internal
55 ( Key
66 , class IDBKey, toKey , fromKey , unsafeFromKey
77 , none
8− , toForeign
98 ) where
109
1110import Prelude
@@ -33,13 +32,6 @@ import Data.Traversable (traverse)
3332newtype Key = Key Foreign
3433
3534
36−toForeign
37− :: Key
38− -> Foreign
39−toForeign (Key f) =
40− f
41−
42−
4335--------------------
4436-- INTERFACES
4537--
@@ -115,6 +107,12 @@ instance idbKeyKey :: IDBKey Key where
115107 unsafeFromKey = id
116108
117109
110+instance idbKeyForeign :: IDBKey Foreign where
111+ toKey = Key
112+ fromKey (Key f) = pure f
113+ unsafeFromKey (Key f) = f
114+
115+
118116instance idbKeyInt :: IDBKey Int where
119117 toKey = Foreign.toForeign >>> Key
120118 fromKey (Key f) = Foreign.readInt f
src/Database/IndexedDB/IDBKeyRange.purs+21−25
@@ -19,7 +19,7 @@ module Database.IndexedDB.IDBKeyRange
1919 , upperOpen
2020 ) where
2121
22−import Prelude (($), (>>>))
22+import Prelude (($), (>>>), map)
2323
2424import Data.Foreign (Foreign)
2525import Data.Function.Uncurried as Fn
@@ -28,7 +28,7 @@ import Data.Maybe (Maybe)
2828import Data.Nullable (Nullable, toMaybe)
2929
3030import Database.IndexedDB.Core (class IDBKeyRange, KeyRange)
31−import Database.IndexedDB.IDBKey.Internal (class IDBKey, toKey, toForeign)
31+import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, toKey, unsafeFromKey)
3232
3333
3434--------------------
@@ -49,7 +49,7 @@ only
4949 => a
5050 -> KeyRange
5151only key =
52− _only (toForeign $ toKey key)
52+ _only (unsafeFromKey $ toKey key)
5353
5454
5555-- | Returns a new IDBKeyRange starting at key with no upper bound.
@@ -60,7 +60,7 @@ lowerBound
6060 -> Open
6161 -> KeyRange
6262lowerBound key open =
63− Fn.runFn2 _lowerBound (toForeign $ toKey key) open
63+ Fn.runFn2 _lowerBound (unsafeFromKey $ toKey key) open
6464
6565
6666-- | Returns a new IDBKeyRange with no lower bound and ending at key.
@@ -71,7 +71,7 @@ upperBound
7171 -> Open
7272 -> KeyRange
7373upperBound key open =
74− Fn.runFn2 _upperBound (toForeign $ toKey key) open
74+ Fn.runFn2 _upperBound (unsafeFromKey $ toKey key) open
7575
7676
7777-- | Returns a new IDBKeyRange spanning from `lower` to `upper`.
@@ -80,12 +80,12 @@ upperBound key open =
8080-- |
8181-- | It throws a `DataError` if the bound is invalid.
8282bound
83− :: forall a. (IDBKey a)
84− => { lower :: a, upper :: a, lowerOpen :: Boolean, upperOpen :: Boolean }
83+ :: forall key. (IDBKey key)
84+ => { lower :: key, upper :: key, lowerOpen :: Boolean, upperOpen :: Boolean }
8585 -> Maybe KeyRange
8686bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } =
8787 toMaybe
88− $ Fn.runFn4 _bound (toForeign $ toKey key1) (toForeign $ toKey key2) open1 open2
88+ $ Fn.runFn4 _bound (unsafeFromKey $ toKey key1) (unsafeFromKey $ toKey key2) open1 open2
8989
9090
9191--------------------
@@ -94,12 +94,12 @@ bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } =
9494
9595-- | Returns true if key is included in the range, and false otherwise.
9696includes
97− :: forall k range. (IDBKey k) => (IDBKeyRange range)
97+ :: forall key range. (IDBKey key) => (IDBKeyRange range)
9898 => range
99− -> k
99+ -> key
100100 -> Boolean
101101includes range =
102− toKey >>> toForeign >>> Fn.runFn2 _includes range
102+ toKey >>> unsafeFromKey >>> Fn.runFn2 _includes range
103103
104104
105105--------------------
@@ -107,20 +107,18 @@ includes range =
107107--
108108-- | Returns lower bound if any.
109109lower
110− :: forall key. (IDBKey key)
111− => KeyRange
112− -> Maybe key
110+ :: KeyRange
111+ -> Maybe Key
113112lower =
114− _lower >>> toMaybe
113+ _lower >>> toMaybe >>> map toKey
115114
116115
117116-- | Returns upper bound if any.
118117upper
119− :: forall key. (IDBKey key)
120− => KeyRange
121− -> Maybe key
118+ :: KeyRange
119+ -> Maybe Key
122120upper =
123− _upper >>> toMaybe
121+ _upper >>> toMaybe >>> map toKey
124122
125123
126124-- | Returns true if the lower open flag is set, false otherwise.
@@ -165,15 +163,13 @@ foreign import _includes
165163
166164
167165foreign import _lower
168− :: forall key. (IDBKey key)
169− => KeyRange
170− -> Nullable key
166+ :: KeyRange
167+ -> Nullable Foreign
171168
172169
173170foreign import _upper
174− :: forall key. (IDBKey key)
175− => KeyRange
176− -> Nullable key
171+ :: KeyRange
172+ -> Nullable Foreign
177173
178174
179175foreign import _lowerOpen
src/Database/IndexedDB/IDBObjectStore.purs+9−9
@@ -36,7 +36,7 @@ import Data.Nullable (Nullable, toNullable)
3636
3737import Database.IndexedDB.Core
3838import Database.IndexedDB.IDBIndex (count, get, getAllKeys, getKey, openCursor, openKeyCursor)
39−import Database.IndexedDB.IDBKey.Internal (class IDBKey, toForeign, toKey)
39+import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, unsafeFromKey, toKey)
4040
4141--------------------
4242-- TYPES
@@ -88,9 +88,9 @@ add
8888 => store
8989 -> val
9090 -> Maybe key
91− -> Aff (idb :: IDB | e) key
91+ -> Aff (idb :: IDB | e) Key
9292add store value key =
93− Fn.runFn3 _add store value (toNullable $ (toKey >>> toForeign) <$> key)
93+ toKey <$> Fn.runFn3 _add store value (toNullable $ (toKey >>> unsafeFromKey) <$> key)
9494
9595
9696-- | Deletes all records in store.
@@ -162,9 +162,9 @@ put
162162 => store
163163 -> val
164164 -> Maybe key
165− -> Aff (idb :: IDB | e) key
165+ -> Aff (idb :: IDB | e) Key
166166put store value key =
167− Fn.runFn3 _put store value (toNullable $ (toKey >>> toForeign) <$> key)
167+ toKey <$> Fn.runFn3 _put store value (toNullable $ (toKey >>> unsafeFromKey) <$> key)
168168
169169
170170--------------------
@@ -214,8 +214,8 @@ transaction =
214214-- FFI
215215--
216216foreign import _add
217− :: forall e key val store. (IDBKey key)
218− => Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) key)
217+ :: forall e val store
218+ . Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) Foreign)
219219
220220
221221foreign import _autoIncrement
@@ -265,8 +265,8 @@ foreign import _name
265265
266266
267267foreign import _put
268− :: forall e key val store. (IDBKey key)
269− => Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) key)
268+ :: forall e val store
269+ . Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) Foreign)
270270
271271
272272foreign import _transaction
test/Main.purs+34−34
@@ -332,7 +332,7 @@ main = runMocha do
332332 putVar var true
333333
334334 var <- makeVar
335− { db, store } <- setup IDBObjectStore.defaultParameters
335+ { db, store } <- setup IDBDatabase.defaultParameters
336336 IDBDatabase.close db
337337 db <- IDBFactory.open "db" (Just 999) { onUpgradeNeeded : Just (onUpgradeNeeded var)
338338 , onBlocked : Nothing
@@ -396,7 +396,7 @@ main = runMocha do
396396
397397 it "clear()" do
398398 { db } <- setup
399− { storeParams: IDBObjectStore.defaultParameters
399+ { storeParams: IDBDatabase.defaultParameters
400400 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
401401 key <- IDBObjectStore.add store "patate" (Just 14)
402402 _ <- IDBObjectStore.clear store
@@ -407,7 +407,7 @@ main = runMocha do
407407
408408 it "count()" do
409409 { db } <- setup
410− { storeParams: IDBObjectStore.defaultParameters
410+ { storeParams: IDBDatabase.defaultParameters
411411 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
412412 key <- IDBObjectStore.add store "patate" (Just 14)
413413 key <- IDBObjectStore.add store "autruche" (Just 42)
@@ -418,7 +418,7 @@ main = runMocha do
418418
419419 it "getKey()" do
420420 { db } <- setup
421− { storeParams: IDBObjectStore.defaultParameters
421+ { storeParams: IDBDatabase.defaultParameters
422422 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
423423 key <- IDBObjectStore.add store "patate" (Just 14)
424424 mkey <- IDBObjectStore.getKey store (IDBKeyRange.only 14)
@@ -431,7 +431,7 @@ main = runMocha do
431431
432432 it "getAllKeys()" do
433433 { db } <- setup
434− { storeParams: IDBObjectStore.defaultParameters
434+ { storeParams: IDBDatabase.defaultParameters
435435 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
436436 key1 <- IDBObjectStore.add store "patate" (Just 14)
437437 key2 <- IDBObjectStore.add store "autruche" (Just 42)
@@ -462,7 +462,7 @@ main = runMocha do
462462 , onComplete: pure unit
463463 }
464464 { db } <- setup
465− { storeParams: IDBObjectStore.defaultParameters
465+ { storeParams: IDBDatabase.defaultParameters
466466 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
467467 _ <- IDBObjectStore.openCursor store Nothing Next cb
468468 _ <- IDBObjectStore.openCursor store Nothing NextUnique cb
@@ -480,7 +480,7 @@ main = runMocha do
480480 , onComplete: pure unit
481481 }
482482 { db } <- setup
483− { storeParams: IDBObjectStore.defaultParameters
483+ { storeParams: IDBDatabase.defaultParameters
484484 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
485485 _ <- IDBObjectStore.openKeyCursor store Nothing Next cb
486486 _ <- IDBObjectStore.openKeyCursor store Nothing NextUnique cb
@@ -523,16 +523,16 @@ main = runMocha do
523523
524524 it "returns an IDBIndex and the properties are set correctly" do
525525 { db, index } <- setup
526− { storeParams : IDBObjectStore.defaultParameters
527− , indexParams : IDBIndex.defaultParameters
526+ { storeParams : IDBDatabase.defaultParameters
527+ , indexParams : IDBObjectStore.defaultParameters
528528 , onUpgradeNeeded : Nothing
529529 , keyPath : []
530530 , values : []
531531 }
532532 IDBIndex.name index `shouldEqual` "index"
533533 IDBIndex.keyPath index `shouldEqual` []
534− IDBIndex.unique index `shouldEqual` IDBIndex.defaultParameters.unique
535− IDBIndex.multiEntry index `shouldEqual` IDBIndex.defaultParameters.multiEntry
534+ IDBIndex.unique index `shouldEqual` IDBObjectStore.defaultParameters.unique
535+ IDBIndex.multiEntry index `shouldEqual` IDBObjectStore.defaultParameters.multiEntry
536536 tearDown db
537537
538538 it "attempt to create an index that requires unique values on an object store already contains duplicates" do
@@ -540,7 +540,7 @@ main = runMocha do
540540 txVar <- makeVar
541541 dbVar <- makeVar
542542 res <- attempt $ setup
543− { storeParams : IDBObjectStore.defaultParameters
543+ { storeParams : IDBDatabase.defaultParameters
544544 , indexParams : { unique : true
545545 , multiEntry : false
546546 }
@@ -565,7 +565,7 @@ main = runMocha do
565565 { storeParams : { keyPath : ["key"]
566566 , autoIncrement : false
567567 }
568− , indexParams : IDBIndex.defaultParameters
568+ , indexParams : IDBObjectStore.defaultParameters
569569 , keyPath : ["indexedProperty"]
570570 , values : [ { key: "key1", indexedProperty: "indexed_1" } :+: Nothing
571571 , { key: "key2", indexedProperty: "indexed_2" } :+: Nothing
@@ -579,8 +579,8 @@ main = runMocha do
579579
580580 it "empty keyPath" do
581581 { db } <- setup
582− { storeParams : IDBObjectStore.defaultParameters
583− , indexParams : IDBIndex.defaultParameters
582+ { storeParams : IDBDatabase.defaultParameters
583+ , indexParams : IDBObjectStore.defaultParameters
584584 , keyPath : []
585585 , values : [ "object_1" :+: (Just $ toKey 1)
586586 , "object_2" :+: (Just $ toKey 2)
@@ -598,7 +598,7 @@ main = runMocha do
598598 { storeParams : { keyPath: ["key"]
599599 , autoIncrement: false
600600 }
601− , indexParams : IDBIndex.defaultParameters
601+ , indexParams : IDBObjectStore.defaultParameters
602602 , keyPath : ["i"]
603603 , values : [ { key: "date", i: (toKey date) } :+: Nothing
604604 ]
@@ -614,7 +614,7 @@ main = runMocha do
614614 { storeParams : { keyPath: ["key"]
615615 , autoIncrement: false
616616 }
617− , indexParams : IDBIndex.defaultParameters
617+ , indexParams : IDBObjectStore.defaultParameters
618618 , keyPath : ["i"]
619619 , values : [ { key: "num", i: (toKey num) } :+: Nothing
620620 ]
@@ -630,7 +630,7 @@ main = runMocha do
630630 { storeParams : { keyPath: ["key"]
631631 , autoIncrement: false
632632 }
633− , indexParams : IDBIndex.defaultParameters
633+ , indexParams : IDBObjectStore.defaultParameters
634634 , keyPath : ["i"]
635635 , values : [ { key: "array", i: (toKey array) } :+: Nothing
636636 ]
@@ -643,7 +643,7 @@ main = runMocha do
643643 it "openKeyCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
644644 res <- attempt $ setup
645645 { storeParams : { keyPath: ["key"], autoIncrement: false }
646− , indexParams : IDBIndex.defaultParameters
646+ , indexParams : IDBObjectStore.defaultParameters
647647 , keyPath : ["indexedProperty"]
648648 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
649649 ]
@@ -668,7 +668,7 @@ main = runMocha do
668668 it "openKeyCursor() - throw TransactionInactiveError on aborted transaction" do
669669 { db } <- setup
670670 { storeParams : { keyPath: ["key"], autoIncrement: false }
671− , indexParams : IDBIndex.defaultParameters
671+ , indexParams : IDBObjectStore.defaultParameters
672672 , keyPath : ["indexedProperty"]
673673 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
674674 ]
@@ -694,7 +694,7 @@ main = runMocha do
694694 it "openKeyCursor() - throw InvalidStateError when the index is deleted" do
695695 { db } <- setup
696696 { storeParams : { keyPath: ["key"], autoIncrement: false }
697− , indexParams : IDBIndex.defaultParameters
697+ , indexParams : IDBObjectStore.defaultParameters
698698 , keyPath : ["indexedProperty"]
699699 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
700700 ]
@@ -717,7 +717,7 @@ main = runMocha do
717717 it "openCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
718718 res <- attempt $ setup
719719 { storeParams : { keyPath: ["key"], autoIncrement: false }
720− , indexParams : IDBIndex.defaultParameters
720+ , indexParams : IDBObjectStore.defaultParameters
721721 , keyPath : ["indexedProperty"]
722722 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
723723 ]
@@ -742,7 +742,7 @@ main = runMocha do
742742 it "openCursor() - throw TransactionInactiveError on aborted transaction" do
743743 { db } <- setup
744744 { storeParams : { keyPath: ["key"], autoIncrement: false }
745− , indexParams : IDBIndex.defaultParameters
745+ , indexParams : IDBObjectStore.defaultParameters
746746 , keyPath : ["indexedProperty"]
747747 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
748748 ]
@@ -768,7 +768,7 @@ main = runMocha do
768768 it "openCursor() - throw InvalidStateError when the index is deleted" do
769769 { db } <- setup
770770 { storeParams : { keyPath: ["key"], autoIncrement: false }
771− , indexParams : IDBIndex.defaultParameters
771+ , indexParams : IDBObjectStore.defaultParameters
772772 , keyPath : ["indexedProperty"]
773773 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
774774 ]
@@ -790,7 +790,7 @@ main = runMocha do
790790
791791 it "getKey() - multiEntry - adding keys" do
792792 { db } <- setup
793− { storeParams : IDBObjectStore.defaultParameters
793+ { storeParams : IDBDatabase.defaultParameters
794794 , indexParams : { unique: false, multiEntry: true }
795795 , keyPath : ["name"]
796796 , values : [ { name: ["patate", "autruche"] } :+: (Just $ toKey 1)
@@ -812,7 +812,7 @@ main = runMocha do
812812 it "get() - returns the record with the first key in the range" do
813813 { db } <- setup
814814 { storeParams : { keyPath: ["key"], autoIncrement: false }
815− , indexParams : IDBIndex.defaultParameters
815+ , indexParams : IDBObjectStore.defaultParameters
816816 , keyPath : ["indexedProperty"]
817817 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
818818 , { key: 42, indexedProperty: "autruche" } :+: Nothing
@@ -860,8 +860,8 @@ main = runMocha do
860860
861861 it "continue() - iterate to the next record" do
862862 { db } <- setup
863− { storeParams : IDBObjectStore.defaultParameters
864− , indexParams : IDBIndex.defaultParameters
863+ { storeParams : IDBDatabase.defaultParameters
864+ , indexParams : IDBObjectStore.defaultParameters
865865 , keyPath : []
866866 , values : [ "cupcake" :+: (Just $ toKey 4)
867867 , "pancake" :+: (Just $ toKey 2)
@@ -899,8 +899,8 @@ main = runMocha do
899899
900900 it "continue() - attempt to iterate in the wrong direction" do
901901 { db } <- setup
902− { storeParams : IDBObjectStore.defaultParameters
903− , indexParams : IDBIndex.defaultParameters
902+ { storeParams : IDBDatabase.defaultParameters
903+ , indexParams : IDBObjectStore.defaultParameters
904904 , keyPath : []
905905 , values : [ "cupcake" :+: (Just $ toKey 4)
906906 , "pancake" :+: (Just $ toKey 2)
@@ -936,7 +936,7 @@ main = runMocha do
936936 it "advance() - iterate cursor number of times specified by count" do
937937 { db } <- setup
938938 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
939− , indexParams : IDBIndex.defaultParameters
939+ , indexParams : IDBObjectStore.defaultParameters
940940 , keyPath : []
941941 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
942942 , { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing
@@ -975,7 +975,7 @@ main = runMocha do
975975 it "delete() - remove a record from the object store" do
976976 { db } <- setup
977977 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
978− , indexParams : IDBIndex.defaultParameters
978+ , indexParams : IDBObjectStore.defaultParameters
979979 , keyPath : []
980980 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
981981 , { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing
@@ -1009,7 +1009,7 @@ main = runMocha do
10091009 it "update() - modify a record in the object store" do
10101010 { db } <- setup
10111011 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
1012− , indexParams : IDBIndex.defaultParameters
1012+ , indexParams : IDBObjectStore.defaultParameters
10131013 , keyPath : []
10141014 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
10151015 ]
@@ -1041,7 +1041,7 @@ main = runMocha do
10411041 it "update() - throw ReadOnlyError after update on ReadOnly transaction" do
10421042 { db } <- setup
10431043 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
1044− , indexParams : IDBIndex.defaultParameters
1044+ , indexParams : IDBObjectStore.defaultParameters
10451045 , keyPath : []
10461046 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
10471047 ]