git.iko.soy/purescript-indexed-DB
on master help sign in
make Key a complete opaque type
24fa04aKtorZ
src/Database/IndexedDB/IDBCursor.purs+20−20
@@ -27,7 +27,7 @@ import Data.Nullable (Nullable, toNullable)
27import Data.String.Read (read)
27import Data.String.Read (read)
28
28
29import Database.IndexedDB.Core
29import Database.IndexedDB.Core
30−import Database.IndexedDB.IDBKey.Internal (class IDBKey, toKey)
30+import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, toKey, unsafeFromKey)
31import Database.IndexedDB.IDBKey.Internal as IDBKey
31import Database.IndexedDB.IDBKey.Internal as IDBKey
32
32
33
33
@@ -52,7 +52,7 @@ continue
52 -> Maybe k
52 -> Maybe k
53 -> Aff (idb :: IDB | e) Unit
53 -> Aff (idb :: IDB | e) Unit
54continue c mk =
54continue c mk =
55− Fn.runFn2 _continue c (toNullable $ map (toKey >>> IDBKey.toForeign) mk)
55+ Fn.runFn2 _continue c (toNullable $ map (toKey >>> unsafeFromKey) mk)
56
56
57
57
58-- | 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.
58-- | 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
63 -> k
63 -> k
64 -> Aff (idb :: IDB | e) Unit
64 -> Aff (idb :: IDB | e) Unit
65continuePrimaryKey c k1 k2 =
65continuePrimaryKey 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)
67
67
68
68
69-- | Delete the record pointed at by the cursor with a new value.
69-- | Delete the record pointed at by the cursor with a new value.
@@ -80,12 +80,12 @@ delete =
80-- | Throws a "DataError" DOMException if the effective object store uses
80-- | Throws a "DataError" DOMException if the effective object store uses
81-- | in-line keys and the key would have changed.
81-- | in-line keys and the key would have changed.
82update
82update
83− :: forall val e cursor key. (IDBCursor cursor) => (IDBKey key)
83+ :: forall val e cursor. (IDBCursor cursor)
84 => cursor
84 => cursor
85 -> val
85 -> val
86− -> Aff (idb :: IDB | e) key
86+ -> Aff (idb :: IDB | e) Key
87update c =
87update c =
88− toForeign >>> Fn.runFn2 _update c
88+ toForeign >>> Fn.runFn2 _update c >>> map toKey
89
89
90
90
91--------------------
91--------------------
@@ -104,21 +104,21 @@ direction =
104-- | Returns the key of the cursor. Throws a "InvalidStateError" DOMException
104-- | Returns the key of the cursor. Throws a "InvalidStateError" DOMException
105-- | if the cursor is advancing or is finished.
105-- | if the cursor is advancing or is finished.
106key
106key
107− :: forall e cursor key. (IDBConcreteCursor cursor) => (IDBKey key)
107+ :: forall e cursor. (IDBConcreteCursor cursor)
108 => cursor
108 => cursor
109− -> Aff (idb :: IDB | e) key
109+ -> Aff (idb :: IDB | e) Key
110key =
110key =
111− _key
111+ _key >>> map toKey
112
112
113
113
114-- | Returns the effective key of the cursor. Throws a "InvalidStateError" DOMException
114-- | Returns the effective key of the cursor. Throws a "InvalidStateError" DOMException
115-- | if the cursor is advancing or is finished.
115-- | if the cursor is advancing or is finished.
116primaryKey
116primaryKey
117− :: forall e cursor key. (IDBConcreteCursor cursor) => (IDBKey key)
117+ :: forall e cursor. (IDBConcreteCursor cursor)
118 => cursor
118 => cursor
119− -> Aff (idb :: IDB | e) key
119+ -> Aff (idb :: IDB | e) Key
120primaryKey =
120primaryKey =
121− _primaryKey
121+ _primaryKey >>> map toKey
122
122
123
123
124-- | Returns the IDBObjectStore or IDBIndex the cursor was opened from.
124-- | Returns the IDBObjectStore or IDBIndex the cursor was opened from.
@@ -169,15 +169,15 @@ foreign import _direction
169
169
170
170
171foreign import _key
171foreign import _key
172− :: forall cursor e key. (IDBKey key)
172+ :: forall cursor e
173− => cursor
173+ . cursor
174− -> Aff (idb :: IDB | e) key
174+ -> Aff (idb :: IDB | e) Key
175
175
176
176
177foreign import _primaryKey
177foreign import _primaryKey
178− :: forall cursor e key. (IDBKey key)
178+ :: forall cursor e
179− => cursor
179+ . cursor
180− -> Aff (idb :: IDB | e) key
180+ -> Aff (idb :: IDB | e) Key
181
181
182
182
183foreign import _source
183foreign import _source
@@ -186,8 +186,8 @@ foreign import _source
186
186
187
187
188foreign import _update
188foreign import _update
189− :: forall cursor e key. (IDBKey key)
189+ :: forall cursor e
190− => Fn2 cursor Foreign (Aff (idb :: IDB | e) key)
190+ . Fn2 cursor Foreign (Aff (idb :: IDB | e) Foreign)
191
191
192
192
193foreign import _value
193foreign import _value
src/Database/IndexedDB/IDBIndex.purs+11−11
@@ -32,7 +32,7 @@ import Data.Maybe (Maybe)
32import Data.Nullable (Nullable, toMaybe, toNullable)
32import Data.Nullable (Nullable, toMaybe, toNullable)
33
33
34import Database.IndexedDB.Core
34import Database.IndexedDB.Core
35−import Database.IndexedDB.IDBKey.Internal (class IDBKey, toKey)
35+import Database.IndexedDB.IDBKey.Internal (Key, toKey)
36
36
37
37
38--------------------
38--------------------
@@ -77,23 +77,23 @@ get index range =
77-- | Retrieves the keys of records matching the given key range in query
77-- | Retrieves the keys of records matching the given key range in query
78-- | (up to the number given if given).
78-- | (up to the number given if given).
79getAllKeys
79getAllKeys
80− :: forall e index key. (IDBIndex index) => (IDBKey key)
80+ :: forall e index. (IDBIndex index)
81 => index
81 => index
82 -> Maybe KeyRange
82 -> Maybe KeyRange
83 -> Maybe Int
83 -> Maybe Int
84− -> Aff (idb :: IDB | e) (Array key)
84+ -> Aff (idb :: IDB | e) (Array Key)
85getAllKeys index range n =
85getAllKeys index range n =
86− Fn.runFn3 _getAllKeys index (toNullable range) (toNullable n)
86+ map toKey <$> Fn.runFn3 _getAllKeys index (toNullable range) (toNullable n)
87
87
88
88
89-- | Retrieves the key of the first record matching the given key or key range in query.
89-- | Retrieves the key of the first record matching the given key or key range in query.
90getKey
90getKey
91− :: forall e index key. (IDBIndex index) => (IDBKey key)
91+ :: forall e index. (IDBIndex index)
92 => index
92 => index
93 -> KeyRange
93 -> KeyRange
94− -> Aff (idb :: IDB | e) (Maybe key)
94+ -> Aff (idb :: IDB | e) (Maybe Key)
95getKey index range =
95getKey index range =
96− toMaybe <$> Fn.runFn2 _getKey index range
96+ (toMaybe >>> map toKey) <$> Fn.runFn2 _getKey index range
97
97
98
98
99-- | Opens a ValueCursor over the records matching query, ordered by direction.
99-- | Opens a ValueCursor over the records matching query, ordered by direction.
@@ -204,13 +204,13 @@ foreign import _get
204
204
205
205
206foreign import _getAllKeys
206foreign import _getAllKeys
207− :: forall index e k. (IDBKey k)
207+ :: forall index e
208− => Fn3 index (Nullable KeyRange) (Nullable Int) (Aff (idb :: IDB | e) (Array k))
208+ . Fn3 index (Nullable KeyRange) (Nullable Int) (Aff (idb :: IDB | e) (Array Foreign))
209
209
210
210
211foreign import _getKey
211foreign import _getKey
212− :: forall index e k. (IDBKey k)
212+ :: forall index e
213− => Fn2 index KeyRange (Aff (idb :: IDB | e) (Nullable k))
213+ . Fn2 index KeyRange (Aff (idb :: IDB | e) (Nullable Foreign))
214
214
215
215
216foreign import _openCursor
216foreign import _openCursor
src/Database/IndexedDB/IDBKey/Internal.purs+6−8
@@ -5,7 +5,6 @@ module Database.IndexedDB.IDBKey.Internal
5 ( Key
5 ( Key
6 , class IDBKey, toKey , fromKey , unsafeFromKey
6 , class IDBKey, toKey , fromKey , unsafeFromKey
7 , none
7 , none
8− , toForeign
9 ) where
8 ) where
10
9
11import Prelude
10import Prelude
@@ -33,13 +32,6 @@ import Data.Traversable (traverse)
33newtype Key = Key Foreign
32newtype Key = Key Foreign
34
33
35
34
36−toForeign
37− :: Key
38− -> Foreign
39−toForeign (Key f) =
40− f
41−
42−
43--------------------
35--------------------
44-- INTERFACES
36-- INTERFACES
45--
37--
@@ -115,6 +107,12 @@ instance idbKeyKey :: IDBKey Key where
115 unsafeFromKey = id
107 unsafeFromKey = id
116
108
117
109
110+instance idbKeyForeign :: IDBKey Foreign where
111+ toKey = Key
112+ fromKey (Key f) = pure f
113+ unsafeFromKey (Key f) = f
114+
115+
118instance idbKeyInt :: IDBKey Int where
116instance idbKeyInt :: IDBKey Int where
119 toKey = Foreign.toForeign >>> Key
117 toKey = Foreign.toForeign >>> Key
120 fromKey (Key f) = Foreign.readInt f
118 fromKey (Key f) = Foreign.readInt f
src/Database/IndexedDB/IDBKeyRange.purs+21−25
@@ -19,7 +19,7 @@ module Database.IndexedDB.IDBKeyRange
19 , upperOpen
19 , upperOpen
20 ) where
20 ) where
21
21
22−import Prelude (($), (>>>))
22+import Prelude (($), (>>>), map)
23
23
24import Data.Foreign (Foreign)
24import Data.Foreign (Foreign)
25import Data.Function.Uncurried as Fn
25import Data.Function.Uncurried as Fn
@@ -28,7 +28,7 @@ import Data.Maybe (Maybe)
28import Data.Nullable (Nullable, toMaybe)
28import Data.Nullable (Nullable, toMaybe)
29
29
30import Database.IndexedDB.Core (class IDBKeyRange, KeyRange)
30import 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)
32
32
33
33
34--------------------
34--------------------
@@ -49,7 +49,7 @@ only
49 => a
49 => a
50 -> KeyRange
50 -> KeyRange
51only key =
51only key =
52− _only (toForeign $ toKey key)
52+ _only (unsafeFromKey $ toKey key)
53
53
54
54
55-- | Returns a new IDBKeyRange starting at key with no upper bound.
55-- | Returns a new IDBKeyRange starting at key with no upper bound.
@@ -60,7 +60,7 @@ lowerBound
60 -> Open
60 -> Open
61 -> KeyRange
61 -> KeyRange
62lowerBound key open =
62lowerBound key open =
63− Fn.runFn2 _lowerBound (toForeign $ toKey key) open
63+ Fn.runFn2 _lowerBound (unsafeFromKey $ toKey key) open
64
64
65
65
66-- | Returns a new IDBKeyRange with no lower bound and ending at key.
66-- | Returns a new IDBKeyRange with no lower bound and ending at key.
@@ -71,7 +71,7 @@ upperBound
71 -> Open
71 -> Open
72 -> KeyRange
72 -> KeyRange
73upperBound key open =
73upperBound key open =
74− Fn.runFn2 _upperBound (toForeign $ toKey key) open
74+ Fn.runFn2 _upperBound (unsafeFromKey $ toKey key) open
75
75
76
76
77-- | Returns a new IDBKeyRange spanning from `lower` to `upper`.
77-- | Returns a new IDBKeyRange spanning from `lower` to `upper`.
@@ -80,12 +80,12 @@ upperBound key open =
80-- |
80-- |
81-- | It throws a `DataError` if the bound is invalid.
81-- | It throws a `DataError` if the bound is invalid.
82bound
82bound
83− :: forall a. (IDBKey a)
83+ :: forall key. (IDBKey key)
84− => { lower :: a, upper :: a, lowerOpen :: Boolean, upperOpen :: Boolean }
84+ => { lower :: key, upper :: key, lowerOpen :: Boolean, upperOpen :: Boolean }
85 -> Maybe KeyRange
85 -> Maybe KeyRange
86bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } =
86bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } =
87 toMaybe
87 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
89
89
90
90
91--------------------
91--------------------
@@ -94,12 +94,12 @@ bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } =
94
94
95-- | Returns true if key is included in the range, and false otherwise.
95-- | Returns true if key is included in the range, and false otherwise.
96includes
96includes
97− :: forall k range. (IDBKey k) => (IDBKeyRange range)
97+ :: forall key range. (IDBKey key) => (IDBKeyRange range)
98 => range
98 => range
99− -> k
99+ -> key
100 -> Boolean
100 -> Boolean
101includes range =
101includes range =
102− toKey >>> toForeign >>> Fn.runFn2 _includes range
102+ toKey >>> unsafeFromKey >>> Fn.runFn2 _includes range
103
103
104
104
105--------------------
105--------------------
@@ -107,20 +107,18 @@ includes range =
107--
107--
108-- | Returns lower bound if any.
108-- | Returns lower bound if any.
109lower
109lower
110− :: forall key. (IDBKey key)
111− => KeyRange
110+ :: KeyRange
112− -> Maybe key
111+ -> Maybe Key
113lower =
112lower =
114− _lower >>> toMaybe
113+ _lower >>> toMaybe >>> map toKey
115
114
116
115
117-- | Returns upper bound if any.
116-- | Returns upper bound if any.
118upper
117upper
119− :: forall key. (IDBKey key)
120− => KeyRange
118+ :: KeyRange
121− -> Maybe key
119+ -> Maybe Key
122upper =
120upper =
123− _upper >>> toMaybe
121+ _upper >>> toMaybe >>> map toKey
124
122
125
123
126-- | Returns true if the lower open flag is set, false otherwise.
124-- | Returns true if the lower open flag is set, false otherwise.
@@ -165,15 +163,13 @@ foreign import _includes
165
163
166
164
167foreign import _lower
165foreign import _lower
168− :: forall key. (IDBKey key)
169− => KeyRange
166+ :: KeyRange
170− -> Nullable key
167+ -> Nullable Foreign
171
168
172
169
173foreign import _upper
170foreign import _upper
174− :: forall key. (IDBKey key)
175− => KeyRange
171+ :: KeyRange
176− -> Nullable key
172+ -> Nullable Foreign
177
173
178
174
179foreign import _lowerOpen
175foreign import _lowerOpen
src/Database/IndexedDB/IDBObjectStore.purs+9−9
@@ -36,7 +36,7 @@ import Data.Nullable (Nullable, toNullable)
36
36
37import Database.IndexedDB.Core
37import Database.IndexedDB.Core
38import Database.IndexedDB.IDBIndex (count, get, getAllKeys, getKey, openCursor, openKeyCursor)
38import 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)
40
40
41--------------------
41--------------------
42-- TYPES
42-- TYPES
@@ -88,9 +88,9 @@ add
88 => store
88 => store
89 -> val
89 -> val
90 -> Maybe key
90 -> Maybe key
91− -> Aff (idb :: IDB | e) key
91+ -> Aff (idb :: IDB | e) Key
92add store value key =
92add store value key =
93− Fn.runFn3 _add store value (toNullable $ (toKey >>> toForeign) <$> key)
93+ toKey <$> Fn.runFn3 _add store value (toNullable $ (toKey >>> unsafeFromKey) <$> key)
94
94
95
95
96-- | Deletes all records in store.
96-- | Deletes all records in store.
@@ -162,9 +162,9 @@ put
162 => store
162 => store
163 -> val
163 -> val
164 -> Maybe key
164 -> Maybe key
165− -> Aff (idb :: IDB | e) key
165+ -> Aff (idb :: IDB | e) Key
166put store value key =
166put store value key =
167− Fn.runFn3 _put store value (toNullable $ (toKey >>> toForeign) <$> key)
167+ toKey <$> Fn.runFn3 _put store value (toNullable $ (toKey >>> unsafeFromKey) <$> key)
168
168
169
169
170--------------------
170--------------------
@@ -214,8 +214,8 @@ transaction =
214-- FFI
214-- FFI
215--
215--
216foreign import _add
216foreign import _add
217− :: forall e key val store. (IDBKey key)
217+ :: forall e val store
218− => Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) key)
218+ . Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) Foreign)
219
219
220
220
221foreign import _autoIncrement
221foreign import _autoIncrement
@@ -265,8 +265,8 @@ foreign import _name
265
265
266
266
267foreign import _put
267foreign import _put
268− :: forall e key val store. (IDBKey key)
268+ :: forall e val store
269− => Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) key)
269+ . Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) Foreign)
270
270
271
271
272foreign import _transaction
272foreign import _transaction
test/Main.purs+34−34
@@ -332,7 +332,7 @@ main = runMocha do
332 putVar var true
332 putVar var true
333
333
334 var <- makeVar
334 var <- makeVar
335− { db, store } <- setup IDBObjectStore.defaultParameters
335+ { db, store } <- setup IDBDatabase.defaultParameters
336 IDBDatabase.close db
336 IDBDatabase.close db
337 db <- IDBFactory.open "db" (Just 999) { onUpgradeNeeded : Just (onUpgradeNeeded var)
337 db <- IDBFactory.open "db" (Just 999) { onUpgradeNeeded : Just (onUpgradeNeeded var)
338 , onBlocked : Nothing
338 , onBlocked : Nothing
@@ -396,7 +396,7 @@ main = runMocha do
396
396
397 it "clear()" do
397 it "clear()" do
398 { db } <- setup
398 { db } <- setup
399− { storeParams: IDBObjectStore.defaultParameters
399+ { storeParams: IDBDatabase.defaultParameters
400 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
400 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
401 key <- IDBObjectStore.add store "patate" (Just 14)
401 key <- IDBObjectStore.add store "patate" (Just 14)
402 _ <- IDBObjectStore.clear store
402 _ <- IDBObjectStore.clear store
@@ -407,7 +407,7 @@ main = runMocha do
407
407
408 it "count()" do
408 it "count()" do
409 { db } <- setup
409 { db } <- setup
410− { storeParams: IDBObjectStore.defaultParameters
410+ { storeParams: IDBDatabase.defaultParameters
411 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
411 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
412 key <- IDBObjectStore.add store "patate" (Just 14)
412 key <- IDBObjectStore.add store "patate" (Just 14)
413 key <- IDBObjectStore.add store "autruche" (Just 42)
413 key <- IDBObjectStore.add store "autruche" (Just 42)
@@ -418,7 +418,7 @@ main = runMocha do
418
418
419 it "getKey()" do
419 it "getKey()" do
420 { db } <- setup
420 { db } <- setup
421− { storeParams: IDBObjectStore.defaultParameters
421+ { storeParams: IDBDatabase.defaultParameters
422 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
422 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
423 key <- IDBObjectStore.add store "patate" (Just 14)
423 key <- IDBObjectStore.add store "patate" (Just 14)
424 mkey <- IDBObjectStore.getKey store (IDBKeyRange.only 14)
424 mkey <- IDBObjectStore.getKey store (IDBKeyRange.only 14)
@@ -431,7 +431,7 @@ main = runMocha do
431
431
432 it "getAllKeys()" do
432 it "getAllKeys()" do
433 { db } <- setup
433 { db } <- setup
434− { storeParams: IDBObjectStore.defaultParameters
434+ { storeParams: IDBDatabase.defaultParameters
435 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
435 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
436 key1 <- IDBObjectStore.add store "patate" (Just 14)
436 key1 <- IDBObjectStore.add store "patate" (Just 14)
437 key2 <- IDBObjectStore.add store "autruche" (Just 42)
437 key2 <- IDBObjectStore.add store "autruche" (Just 42)
@@ -462,7 +462,7 @@ main = runMocha do
462 , onComplete: pure unit
462 , onComplete: pure unit
463 }
463 }
464 { db } <- setup
464 { db } <- setup
465− { storeParams: IDBObjectStore.defaultParameters
465+ { storeParams: IDBDatabase.defaultParameters
466 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
466 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
467 _ <- IDBObjectStore.openCursor store Nothing Next cb
467 _ <- IDBObjectStore.openCursor store Nothing Next cb
468 _ <- IDBObjectStore.openCursor store Nothing NextUnique cb
468 _ <- IDBObjectStore.openCursor store Nothing NextUnique cb
@@ -480,7 +480,7 @@ main = runMocha do
480 , onComplete: pure unit
480 , onComplete: pure unit
481 }
481 }
482 { db } <- setup
482 { db } <- setup
483− { storeParams: IDBObjectStore.defaultParameters
483+ { storeParams: IDBDatabase.defaultParameters
484 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
484 , onUpgradeNeeded: Just $ \_ store -> launchAff' do
485 _ <- IDBObjectStore.openKeyCursor store Nothing Next cb
485 _ <- IDBObjectStore.openKeyCursor store Nothing Next cb
486 _ <- IDBObjectStore.openKeyCursor store Nothing NextUnique cb
486 _ <- IDBObjectStore.openKeyCursor store Nothing NextUnique cb
@@ -523,16 +523,16 @@ main = runMocha do
523
523
524 it "returns an IDBIndex and the properties are set correctly" do
524 it "returns an IDBIndex and the properties are set correctly" do
525 { db, index } <- setup
525 { db, index } <- setup
526− { storeParams : IDBObjectStore.defaultParameters
526+ { storeParams : IDBDatabase.defaultParameters
527− , indexParams : IDBIndex.defaultParameters
527+ , indexParams : IDBObjectStore.defaultParameters
528 , onUpgradeNeeded : Nothing
528 , onUpgradeNeeded : Nothing
529 , keyPath : []
529 , keyPath : []
530 , values : []
530 , values : []
531 }
531 }
532 IDBIndex.name index `shouldEqual` "index"
532 IDBIndex.name index `shouldEqual` "index"
533 IDBIndex.keyPath index `shouldEqual` []
533 IDBIndex.keyPath index `shouldEqual` []
534− IDBIndex.unique index `shouldEqual` IDBIndex.defaultParameters.unique
534+ IDBIndex.unique index `shouldEqual` IDBObjectStore.defaultParameters.unique
535− IDBIndex.multiEntry index `shouldEqual` IDBIndex.defaultParameters.multiEntry
535+ IDBIndex.multiEntry index `shouldEqual` IDBObjectStore.defaultParameters.multiEntry
536 tearDown db
536 tearDown db
537
537
538 it "attempt to create an index that requires unique values on an object store already contains duplicates" do
538 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
540 txVar <- makeVar
540 txVar <- makeVar
541 dbVar <- makeVar
541 dbVar <- makeVar
542 res <- attempt $ setup
542 res <- attempt $ setup
543− { storeParams : IDBObjectStore.defaultParameters
543+ { storeParams : IDBDatabase.defaultParameters
544 , indexParams : { unique : true
544 , indexParams : { unique : true
545 , multiEntry : false
545 , multiEntry : false
546 }
546 }
@@ -565,7 +565,7 @@ main = runMocha do
565 { storeParams : { keyPath : ["key"]
565 { storeParams : { keyPath : ["key"]
566 , autoIncrement : false
566 , autoIncrement : false
567 }
567 }
568− , indexParams : IDBIndex.defaultParameters
568+ , indexParams : IDBObjectStore.defaultParameters
569 , keyPath : ["indexedProperty"]
569 , keyPath : ["indexedProperty"]
570 , values : [ { key: "key1", indexedProperty: "indexed_1" } :+: Nothing
570 , values : [ { key: "key1", indexedProperty: "indexed_1" } :+: Nothing
571 , { key: "key2", indexedProperty: "indexed_2" } :+: Nothing
571 , { key: "key2", indexedProperty: "indexed_2" } :+: Nothing
@@ -579,8 +579,8 @@ main = runMocha do
579
579
580 it "empty keyPath" do
580 it "empty keyPath" do
581 { db } <- setup
581 { db } <- setup
582− { storeParams : IDBObjectStore.defaultParameters
582+ { storeParams : IDBDatabase.defaultParameters
583− , indexParams : IDBIndex.defaultParameters
583+ , indexParams : IDBObjectStore.defaultParameters
584 , keyPath : []
584 , keyPath : []
585 , values : [ "object_1" :+: (Just $ toKey 1)
585 , values : [ "object_1" :+: (Just $ toKey 1)
586 , "object_2" :+: (Just $ toKey 2)
586 , "object_2" :+: (Just $ toKey 2)
@@ -598,7 +598,7 @@ main = runMocha do
598 { storeParams : { keyPath: ["key"]
598 { storeParams : { keyPath: ["key"]
599 , autoIncrement: false
599 , autoIncrement: false
600 }
600 }
601− , indexParams : IDBIndex.defaultParameters
601+ , indexParams : IDBObjectStore.defaultParameters
602 , keyPath : ["i"]
602 , keyPath : ["i"]
603 , values : [ { key: "date", i: (toKey date) } :+: Nothing
603 , values : [ { key: "date", i: (toKey date) } :+: Nothing
604 ]
604 ]
@@ -614,7 +614,7 @@ main = runMocha do
614 { storeParams : { keyPath: ["key"]
614 { storeParams : { keyPath: ["key"]
615 , autoIncrement: false
615 , autoIncrement: false
616 }
616 }
617− , indexParams : IDBIndex.defaultParameters
617+ , indexParams : IDBObjectStore.defaultParameters
618 , keyPath : ["i"]
618 , keyPath : ["i"]
619 , values : [ { key: "num", i: (toKey num) } :+: Nothing
619 , values : [ { key: "num", i: (toKey num) } :+: Nothing
620 ]
620 ]
@@ -630,7 +630,7 @@ main = runMocha do
630 { storeParams : { keyPath: ["key"]
630 { storeParams : { keyPath: ["key"]
631 , autoIncrement: false
631 , autoIncrement: false
632 }
632 }
633− , indexParams : IDBIndex.defaultParameters
633+ , indexParams : IDBObjectStore.defaultParameters
634 , keyPath : ["i"]
634 , keyPath : ["i"]
635 , values : [ { key: "array", i: (toKey array) } :+: Nothing
635 , values : [ { key: "array", i: (toKey array) } :+: Nothing
636 ]
636 ]
@@ -643,7 +643,7 @@ main = runMocha do
643 it "openKeyCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
643 it "openKeyCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
644 res <- attempt $ setup
644 res <- attempt $ setup
645 { storeParams : { keyPath: ["key"], autoIncrement: false }
645 { storeParams : { keyPath: ["key"], autoIncrement: false }
646− , indexParams : IDBIndex.defaultParameters
646+ , indexParams : IDBObjectStore.defaultParameters
647 , keyPath : ["indexedProperty"]
647 , keyPath : ["indexedProperty"]
648 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
648 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
649 ]
649 ]
@@ -668,7 +668,7 @@ main = runMocha do
668 it "openKeyCursor() - throw TransactionInactiveError on aborted transaction" do
668 it "openKeyCursor() - throw TransactionInactiveError on aborted transaction" do
669 { db } <- setup
669 { db } <- setup
670 { storeParams : { keyPath: ["key"], autoIncrement: false }
670 { storeParams : { keyPath: ["key"], autoIncrement: false }
671− , indexParams : IDBIndex.defaultParameters
671+ , indexParams : IDBObjectStore.defaultParameters
672 , keyPath : ["indexedProperty"]
672 , keyPath : ["indexedProperty"]
673 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
673 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
674 ]
674 ]
@@ -694,7 +694,7 @@ main = runMocha do
694 it "openKeyCursor() - throw InvalidStateError when the index is deleted" do
694 it "openKeyCursor() - throw InvalidStateError when the index is deleted" do
695 { db } <- setup
695 { db } <- setup
696 { storeParams : { keyPath: ["key"], autoIncrement: false }
696 { storeParams : { keyPath: ["key"], autoIncrement: false }
697− , indexParams : IDBIndex.defaultParameters
697+ , indexParams : IDBObjectStore.defaultParameters
698 , keyPath : ["indexedProperty"]
698 , keyPath : ["indexedProperty"]
699 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
699 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
700 ]
700 ]
@@ -717,7 +717,7 @@ main = runMocha do
717 it "openCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
717 it "openCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
718 res <- attempt $ setup
718 res <- attempt $ setup
719 { storeParams : { keyPath: ["key"], autoIncrement: false }
719 { storeParams : { keyPath: ["key"], autoIncrement: false }
720− , indexParams : IDBIndex.defaultParameters
720+ , indexParams : IDBObjectStore.defaultParameters
721 , keyPath : ["indexedProperty"]
721 , keyPath : ["indexedProperty"]
722 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
722 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
723 ]
723 ]
@@ -742,7 +742,7 @@ main = runMocha do
742 it "openCursor() - throw TransactionInactiveError on aborted transaction" do
742 it "openCursor() - throw TransactionInactiveError on aborted transaction" do
743 { db } <- setup
743 { db } <- setup
744 { storeParams : { keyPath: ["key"], autoIncrement: false }
744 { storeParams : { keyPath: ["key"], autoIncrement: false }
745− , indexParams : IDBIndex.defaultParameters
745+ , indexParams : IDBObjectStore.defaultParameters
746 , keyPath : ["indexedProperty"]
746 , keyPath : ["indexedProperty"]
747 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
747 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
748 ]
748 ]
@@ -768,7 +768,7 @@ main = runMocha do
768 it "openCursor() - throw InvalidStateError when the index is deleted" do
768 it "openCursor() - throw InvalidStateError when the index is deleted" do
769 { db } <- setup
769 { db } <- setup
770 { storeParams : { keyPath: ["key"], autoIncrement: false }
770 { storeParams : { keyPath: ["key"], autoIncrement: false }
771− , indexParams : IDBIndex.defaultParameters
771+ , indexParams : IDBObjectStore.defaultParameters
772 , keyPath : ["indexedProperty"]
772 , keyPath : ["indexedProperty"]
773 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
773 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
774 ]
774 ]
@@ -790,7 +790,7 @@ main = runMocha do
790
790
791 it "getKey() - multiEntry - adding keys" do
791 it "getKey() - multiEntry - adding keys" do
792 { db } <- setup
792 { db } <- setup
793− { storeParams : IDBObjectStore.defaultParameters
793+ { storeParams : IDBDatabase.defaultParameters
794 , indexParams : { unique: false, multiEntry: true }
794 , indexParams : { unique: false, multiEntry: true }
795 , keyPath : ["name"]
795 , keyPath : ["name"]
796 , values : [ { name: ["patate", "autruche"] } :+: (Just $ toKey 1)
796 , values : [ { name: ["patate", "autruche"] } :+: (Just $ toKey 1)
@@ -812,7 +812,7 @@ main = runMocha do
812 it "get() - returns the record with the first key in the range" do
812 it "get() - returns the record with the first key in the range" do
813 { db } <- setup
813 { db } <- setup
814 { storeParams : { keyPath: ["key"], autoIncrement: false }
814 { storeParams : { keyPath: ["key"], autoIncrement: false }
815− , indexParams : IDBIndex.defaultParameters
815+ , indexParams : IDBObjectStore.defaultParameters
816 , keyPath : ["indexedProperty"]
816 , keyPath : ["indexedProperty"]
817 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
817 , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
818 , { key: 42, indexedProperty: "autruche" } :+: Nothing
818 , { key: 42, indexedProperty: "autruche" } :+: Nothing
@@ -860,8 +860,8 @@ main = runMocha do
860
860
861 it "continue() - iterate to the next record" do
861 it "continue() - iterate to the next record" do
862 { db } <- setup
862 { db } <- setup
863− { storeParams : IDBObjectStore.defaultParameters
863+ { storeParams : IDBDatabase.defaultParameters
864− , indexParams : IDBIndex.defaultParameters
864+ , indexParams : IDBObjectStore.defaultParameters
865 , keyPath : []
865 , keyPath : []
866 , values : [ "cupcake" :+: (Just $ toKey 4)
866 , values : [ "cupcake" :+: (Just $ toKey 4)
867 , "pancake" :+: (Just $ toKey 2)
867 , "pancake" :+: (Just $ toKey 2)
@@ -899,8 +899,8 @@ main = runMocha do
899
899
900 it "continue() - attempt to iterate in the wrong direction" do
900 it "continue() - attempt to iterate in the wrong direction" do
901 { db } <- setup
901 { db } <- setup
902− { storeParams : IDBObjectStore.defaultParameters
902+ { storeParams : IDBDatabase.defaultParameters
903− , indexParams : IDBIndex.defaultParameters
903+ , indexParams : IDBObjectStore.defaultParameters
904 , keyPath : []
904 , keyPath : []
905 , values : [ "cupcake" :+: (Just $ toKey 4)
905 , values : [ "cupcake" :+: (Just $ toKey 4)
906 , "pancake" :+: (Just $ toKey 2)
906 , "pancake" :+: (Just $ toKey 2)
@@ -936,7 +936,7 @@ main = runMocha do
936 it "advance() - iterate cursor number of times specified by count" do
936 it "advance() - iterate cursor number of times specified by count" do
937 { db } <- setup
937 { db } <- setup
938 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
938 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
939− , indexParams : IDBIndex.defaultParameters
939+ , indexParams : IDBObjectStore.defaultParameters
940 , keyPath : []
940 , keyPath : []
941 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
941 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
942 , { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing
942 , { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing
@@ -975,7 +975,7 @@ main = runMocha do
975 it "delete() - remove a record from the object store" do
975 it "delete() - remove a record from the object store" do
976 { db } <- setup
976 { db } <- setup
977 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
977 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
978− , indexParams : IDBIndex.defaultParameters
978+ , indexParams : IDBObjectStore.defaultParameters
979 , keyPath : []
979 , keyPath : []
980 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
980 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
981 , { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing
981 , { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing
@@ -1009,7 +1009,7 @@ main = runMocha do
1009 it "update() - modify a record in the object store" do
1009 it "update() - modify a record in the object store" do
1010 { db } <- setup
1010 { db } <- setup
1011 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
1011 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
1012− , indexParams : IDBIndex.defaultParameters
1012+ , indexParams : IDBObjectStore.defaultParameters
1013 , keyPath : []
1013 , keyPath : []
1014 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
1014 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
1015 ]
1015 ]
@@ -1041,7 +1041,7 @@ main = runMocha do
1041 it "update() - throw ReadOnlyError after update on ReadOnly transaction" do
1041 it "update() - throw ReadOnlyError after update on ReadOnly transaction" do
1042 { db } <- setup
1042 { db } <- setup
1043 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
1043 { storeParams : { keyPath: ["pKey"], autoIncrement: false }
1044− , indexParams : IDBIndex.defaultParameters
1044+ , indexParams : IDBObjectStore.defaultParameters
1045 , keyPath : []
1045 , keyPath : []
1046 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
1046 , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
1047 ]
1047 ]