make Key a complete opaque type

This commit is contained in:
KtorZ 2017-07-28 11:12:54 +02:00
parent 3b53339870
commit 24fa04adcb
No known key found for this signature in database
GPG Key ID: 3F72E8BC2894C015
6 changed files with 101 additions and 107 deletions

View File

@ -27,7 +27,7 @@ import Data.Nullable (Nullable, toNullable)
import Data.String.Read (read) import Data.String.Read (read)
import Database.IndexedDB.Core import Database.IndexedDB.Core
import Database.IndexedDB.IDBKey.Internal (class IDBKey, toKey) import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, toKey, unsafeFromKey)
import Database.IndexedDB.IDBKey.Internal as IDBKey import Database.IndexedDB.IDBKey.Internal as IDBKey
@ -52,7 +52,7 @@ continue
-> Maybe k -> Maybe k
-> Aff (idb :: IDB | e) Unit -> Aff (idb :: IDB | e) Unit
continue c mk = continue c mk =
Fn.runFn2 _continue c (toNullable $ map (toKey >>> IDBKey.toForeign) mk) Fn.runFn2 _continue c (toNullable $ map (toKey >>> unsafeFromKey) mk)
-- | 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. -- | 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
-> k -> k
-> Aff (idb :: IDB | e) Unit -> Aff (idb :: IDB | e) Unit
continuePrimaryKey c k1 k2 = continuePrimaryKey c k1 k2 =
Fn.runFn3 _continuePrimaryKey c (IDBKey.toForeign $ toKey k1) (IDBKey.toForeign $ toKey k2) Fn.runFn3 _continuePrimaryKey c (unsafeFromKey $ toKey k1) (unsafeFromKey $ toKey k2)
-- | Delete the record pointed at by the cursor with a new value. -- | Delete the record pointed at by the cursor with a new value.
@ -80,12 +80,12 @@ delete =
-- | Throws a "DataError" DOMException if the effective object store uses -- | Throws a "DataError" DOMException if the effective object store uses
-- | in-line keys and the key would have changed. -- | in-line keys and the key would have changed.
update update
:: forall val e cursor key. (IDBCursor cursor) => (IDBKey key) :: forall val e cursor. (IDBCursor cursor)
=> cursor => cursor
-> val -> val
-> Aff (idb :: IDB | e) key -> Aff (idb :: IDB | e) Key
update c = update c =
toForeign >>> Fn.runFn2 _update c toForeign >>> Fn.runFn2 _update c >>> map toKey
-------------------- --------------------
@ -104,21 +104,21 @@ direction =
-- | Returns the key of the cursor. Throws a "InvalidStateError" DOMException -- | Returns the key of the cursor. Throws a "InvalidStateError" DOMException
-- | if the cursor is advancing or is finished. -- | if the cursor is advancing or is finished.
key key
:: forall e cursor key. (IDBConcreteCursor cursor) => (IDBKey key) :: forall e cursor. (IDBConcreteCursor cursor)
=> cursor => cursor
-> Aff (idb :: IDB | e) key -> Aff (idb :: IDB | e) Key
key = key =
_key _key >>> map toKey
-- | Returns the effective key of the cursor. Throws a "InvalidStateError" DOMException -- | Returns the effective key of the cursor. Throws a "InvalidStateError" DOMException
-- | if the cursor is advancing or is finished. -- | if the cursor is advancing or is finished.
primaryKey primaryKey
:: forall e cursor key. (IDBConcreteCursor cursor) => (IDBKey key) :: forall e cursor. (IDBConcreteCursor cursor)
=> cursor => cursor
-> Aff (idb :: IDB | e) key -> Aff (idb :: IDB | e) Key
primaryKey = primaryKey =
_primaryKey _primaryKey >>> map toKey
-- | Returns the IDBObjectStore or IDBIndex the cursor was opened from. -- | Returns the IDBObjectStore or IDBIndex the cursor was opened from.
@ -169,15 +169,15 @@ foreign import _direction
foreign import _key foreign import _key
:: forall cursor e key. (IDBKey key) :: forall cursor e
=> cursor . cursor
-> Aff (idb :: IDB | e) key -> Aff (idb :: IDB | e) Key
foreign import _primaryKey foreign import _primaryKey
:: forall cursor e key. (IDBKey key) :: forall cursor e
=> cursor . cursor
-> Aff (idb :: IDB | e) key -> Aff (idb :: IDB | e) Key
foreign import _source foreign import _source
@ -186,8 +186,8 @@ foreign import _source
foreign import _update foreign import _update
:: forall cursor e key. (IDBKey key) :: forall cursor e
=> Fn2 cursor Foreign (Aff (idb :: IDB | e) key) . Fn2 cursor Foreign (Aff (idb :: IDB | e) Foreign)
foreign import _value foreign import _value

View File

@ -32,7 +32,7 @@ import Data.Maybe (Maybe)
import Data.Nullable (Nullable, toMaybe, toNullable) import Data.Nullable (Nullable, toMaybe, toNullable)
import Database.IndexedDB.Core import Database.IndexedDB.Core
import Database.IndexedDB.IDBKey.Internal (class IDBKey, toKey) import Database.IndexedDB.IDBKey.Internal (Key, toKey)
-------------------- --------------------
@ -77,23 +77,23 @@ get index range =
-- | Retrieves the keys of records matching the given key range in query -- | Retrieves the keys of records matching the given key range in query
-- | (up to the number given if given). -- | (up to the number given if given).
getAllKeys getAllKeys
:: forall e index key. (IDBIndex index) => (IDBKey key) :: forall e index. (IDBIndex index)
=> index => index
-> Maybe KeyRange -> Maybe KeyRange
-> Maybe Int -> Maybe Int
-> Aff (idb :: IDB | e) (Array key) -> Aff (idb :: IDB | e) (Array Key)
getAllKeys index range n = getAllKeys index range n =
Fn.runFn3 _getAllKeys index (toNullable range) (toNullable n) map toKey <$> Fn.runFn3 _getAllKeys index (toNullable range) (toNullable n)
-- | Retrieves the key of the first record matching the given key or key range in query. -- | Retrieves the key of the first record matching the given key or key range in query.
getKey getKey
:: forall e index key. (IDBIndex index) => (IDBKey key) :: forall e index. (IDBIndex index)
=> index => index
-> KeyRange -> KeyRange
-> Aff (idb :: IDB | e) (Maybe key) -> Aff (idb :: IDB | e) (Maybe Key)
getKey index range = getKey index range =
toMaybe <$> Fn.runFn2 _getKey index range (toMaybe >>> map toKey) <$> Fn.runFn2 _getKey index range
-- | Opens a ValueCursor over the records matching query, ordered by direction. -- | Opens a ValueCursor over the records matching query, ordered by direction.
@ -204,13 +204,13 @@ foreign import _get
foreign import _getAllKeys foreign import _getAllKeys
:: forall index e k. (IDBKey k) :: forall index e
=> Fn3 index (Nullable KeyRange) (Nullable Int) (Aff (idb :: IDB | e) (Array k)) . Fn3 index (Nullable KeyRange) (Nullable Int) (Aff (idb :: IDB | e) (Array Foreign))
foreign import _getKey foreign import _getKey
:: forall index e k. (IDBKey k) :: forall index e
=> Fn2 index KeyRange (Aff (idb :: IDB | e) (Nullable k)) . Fn2 index KeyRange (Aff (idb :: IDB | e) (Nullable Foreign))
foreign import _openCursor foreign import _openCursor

View File

@ -5,7 +5,6 @@ module Database.IndexedDB.IDBKey.Internal
( Key ( Key
, class IDBKey, toKey , fromKey , unsafeFromKey , class IDBKey, toKey , fromKey , unsafeFromKey
, none , none
, toForeign
) where ) where
import Prelude import Prelude
@ -33,13 +32,6 @@ import Data.Traversable (traverse)
newtype Key = Key Foreign newtype Key = Key Foreign
toForeign
:: Key
-> Foreign
toForeign (Key f) =
f
-------------------- --------------------
-- INTERFACES -- INTERFACES
-- --
@ -115,6 +107,12 @@ instance idbKeyKey :: IDBKey Key where
unsafeFromKey = id unsafeFromKey = id
instance idbKeyForeign :: IDBKey Foreign where
toKey = Key
fromKey (Key f) = pure f
unsafeFromKey (Key f) = f
instance idbKeyInt :: IDBKey Int where instance idbKeyInt :: IDBKey Int where
toKey = Foreign.toForeign >>> Key toKey = Foreign.toForeign >>> Key
fromKey (Key f) = Foreign.readInt f fromKey (Key f) = Foreign.readInt f

View File

@ -19,7 +19,7 @@ module Database.IndexedDB.IDBKeyRange
, upperOpen , upperOpen
) where ) where
import Prelude (($), (>>>)) import Prelude (($), (>>>), map)
import Data.Foreign (Foreign) import Data.Foreign (Foreign)
import Data.Function.Uncurried as Fn import Data.Function.Uncurried as Fn
@ -28,7 +28,7 @@ import Data.Maybe (Maybe)
import Data.Nullable (Nullable, toMaybe) import Data.Nullable (Nullable, toMaybe)
import Database.IndexedDB.Core (class IDBKeyRange, KeyRange) import Database.IndexedDB.Core (class IDBKeyRange, KeyRange)
import Database.IndexedDB.IDBKey.Internal (class IDBKey, toKey, toForeign) import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, toKey, unsafeFromKey)
-------------------- --------------------
@ -49,7 +49,7 @@ only
=> a => a
-> KeyRange -> KeyRange
only key = only key =
_only (toForeign $ toKey key) _only (unsafeFromKey $ toKey key)
-- | Returns a new IDBKeyRange starting at key with no upper bound. -- | Returns a new IDBKeyRange starting at key with no upper bound.
@ -60,7 +60,7 @@ lowerBound
-> Open -> Open
-> KeyRange -> KeyRange
lowerBound key open = lowerBound key open =
Fn.runFn2 _lowerBound (toForeign $ toKey key) open Fn.runFn2 _lowerBound (unsafeFromKey $ toKey key) open
-- | Returns a new IDBKeyRange with no lower bound and ending at key. -- | Returns a new IDBKeyRange with no lower bound and ending at key.
@ -71,7 +71,7 @@ upperBound
-> Open -> Open
-> KeyRange -> KeyRange
upperBound key open = upperBound key open =
Fn.runFn2 _upperBound (toForeign $ toKey key) open Fn.runFn2 _upperBound (unsafeFromKey $ toKey key) open
-- | Returns a new IDBKeyRange spanning from `lower` to `upper`. -- | Returns a new IDBKeyRange spanning from `lower` to `upper`.
@ -80,12 +80,12 @@ upperBound key open =
-- | -- |
-- | It throws a `DataError` if the bound is invalid. -- | It throws a `DataError` if the bound is invalid.
bound bound
:: forall a. (IDBKey a) :: forall key. (IDBKey key)
=> { lower :: a, upper :: a, lowerOpen :: Boolean, upperOpen :: Boolean } => { lower :: key, upper :: key, lowerOpen :: Boolean, upperOpen :: Boolean }
-> Maybe KeyRange -> Maybe KeyRange
bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } = bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } =
toMaybe toMaybe
$ Fn.runFn4 _bound (toForeign $ toKey key1) (toForeign $ toKey key2) open1 open2 $ Fn.runFn4 _bound (unsafeFromKey $ toKey key1) (unsafeFromKey $ toKey key2) open1 open2
-------------------- --------------------
@ -94,12 +94,12 @@ bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } =
-- | Returns true if key is included in the range, and false otherwise. -- | Returns true if key is included in the range, and false otherwise.
includes includes
:: forall k range. (IDBKey k) => (IDBKeyRange range) :: forall key range. (IDBKey key) => (IDBKeyRange range)
=> range => range
-> k -> key
-> Boolean -> Boolean
includes range = includes range =
toKey >>> toForeign >>> Fn.runFn2 _includes range toKey >>> unsafeFromKey >>> Fn.runFn2 _includes range
-------------------- --------------------
@ -107,20 +107,18 @@ includes range =
-- --
-- | Returns lower bound if any. -- | Returns lower bound if any.
lower lower
:: forall key. (IDBKey key) :: KeyRange
=> KeyRange -> Maybe Key
-> Maybe key
lower = lower =
_lower >>> toMaybe _lower >>> toMaybe >>> map toKey
-- | Returns upper bound if any. -- | Returns upper bound if any.
upper upper
:: forall key. (IDBKey key) :: KeyRange
=> KeyRange -> Maybe Key
-> Maybe key
upper = upper =
_upper >>> toMaybe _upper >>> toMaybe >>> map toKey
-- | Returns true if the lower open flag is set, false otherwise. -- | Returns true if the lower open flag is set, false otherwise.
@ -165,15 +163,13 @@ foreign import _includes
foreign import _lower foreign import _lower
:: forall key. (IDBKey key) :: KeyRange
=> KeyRange -> Nullable Foreign
-> Nullable key
foreign import _upper foreign import _upper
:: forall key. (IDBKey key) :: KeyRange
=> KeyRange -> Nullable Foreign
-> Nullable key
foreign import _lowerOpen foreign import _lowerOpen

View File

@ -36,7 +36,7 @@ import Data.Nullable (Nullable, toNullable)
import Database.IndexedDB.Core import Database.IndexedDB.Core
import Database.IndexedDB.IDBIndex (count, get, getAllKeys, getKey, openCursor, openKeyCursor) import Database.IndexedDB.IDBIndex (count, get, getAllKeys, getKey, openCursor, openKeyCursor)
import Database.IndexedDB.IDBKey.Internal (class IDBKey, toForeign, toKey) import Database.IndexedDB.IDBKey.Internal (class IDBKey, Key, unsafeFromKey, toKey)
-------------------- --------------------
-- TYPES -- TYPES
@ -88,9 +88,9 @@ add
=> store => store
-> val -> val
-> Maybe key -> Maybe key
-> Aff (idb :: IDB | e) key -> Aff (idb :: IDB | e) Key
add store value key = add store value key =
Fn.runFn3 _add store value (toNullable $ (toKey >>> toForeign) <$> key) toKey <$> Fn.runFn3 _add store value (toNullable $ (toKey >>> unsafeFromKey) <$> key)
-- | Deletes all records in store. -- | Deletes all records in store.
@ -162,9 +162,9 @@ put
=> store => store
-> val -> val
-> Maybe key -> Maybe key
-> Aff (idb :: IDB | e) key -> Aff (idb :: IDB | e) Key
put store value key = put store value key =
Fn.runFn3 _put store value (toNullable $ (toKey >>> toForeign) <$> key) toKey <$> Fn.runFn3 _put store value (toNullable $ (toKey >>> unsafeFromKey) <$> key)
-------------------- --------------------
@ -214,8 +214,8 @@ transaction =
-- FFI -- FFI
-- --
foreign import _add foreign import _add
:: forall e key val store. (IDBKey key) :: forall e val store
=> Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) key) . Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) Foreign)
foreign import _autoIncrement foreign import _autoIncrement
@ -265,8 +265,8 @@ foreign import _name
foreign import _put foreign import _put
:: forall e key val store. (IDBKey key) :: forall e val store
=> Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) key) . Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) Foreign)
foreign import _transaction foreign import _transaction

View File

@ -332,7 +332,7 @@ main = runMocha do
putVar var true putVar var true
var <- makeVar var <- makeVar
{ db, store } <- setup IDBObjectStore.defaultParameters { db, store } <- setup IDBDatabase.defaultParameters
IDBDatabase.close db IDBDatabase.close db
db <- IDBFactory.open "db" (Just 999) { onUpgradeNeeded : Just (onUpgradeNeeded var) db <- IDBFactory.open "db" (Just 999) { onUpgradeNeeded : Just (onUpgradeNeeded var)
, onBlocked : Nothing , onBlocked : Nothing
@ -396,7 +396,7 @@ main = runMocha do
it "clear()" do it "clear()" do
{ db } <- setup { db } <- setup
{ storeParams: IDBObjectStore.defaultParameters { storeParams: IDBDatabase.defaultParameters
, onUpgradeNeeded: Just $ \_ store -> launchAff' do , onUpgradeNeeded: Just $ \_ store -> launchAff' do
key <- IDBObjectStore.add store "patate" (Just 14) key <- IDBObjectStore.add store "patate" (Just 14)
_ <- IDBObjectStore.clear store _ <- IDBObjectStore.clear store
@ -407,7 +407,7 @@ main = runMocha do
it "count()" do it "count()" do
{ db } <- setup { db } <- setup
{ storeParams: IDBObjectStore.defaultParameters { storeParams: IDBDatabase.defaultParameters
, onUpgradeNeeded: Just $ \_ store -> launchAff' do , onUpgradeNeeded: Just $ \_ store -> launchAff' do
key <- IDBObjectStore.add store "patate" (Just 14) key <- IDBObjectStore.add store "patate" (Just 14)
key <- IDBObjectStore.add store "autruche" (Just 42) key <- IDBObjectStore.add store "autruche" (Just 42)
@ -418,7 +418,7 @@ main = runMocha do
it "getKey()" do it "getKey()" do
{ db } <- setup { db } <- setup
{ storeParams: IDBObjectStore.defaultParameters { storeParams: IDBDatabase.defaultParameters
, onUpgradeNeeded: Just $ \_ store -> launchAff' do , onUpgradeNeeded: Just $ \_ store -> launchAff' do
key <- IDBObjectStore.add store "patate" (Just 14) key <- IDBObjectStore.add store "patate" (Just 14)
mkey <- IDBObjectStore.getKey store (IDBKeyRange.only 14) mkey <- IDBObjectStore.getKey store (IDBKeyRange.only 14)
@ -431,7 +431,7 @@ main = runMocha do
it "getAllKeys()" do it "getAllKeys()" do
{ db } <- setup { db } <- setup
{ storeParams: IDBObjectStore.defaultParameters { storeParams: IDBDatabase.defaultParameters
, onUpgradeNeeded: Just $ \_ store -> launchAff' do , onUpgradeNeeded: Just $ \_ store -> launchAff' do
key1 <- IDBObjectStore.add store "patate" (Just 14) key1 <- IDBObjectStore.add store "patate" (Just 14)
key2 <- IDBObjectStore.add store "autruche" (Just 42) key2 <- IDBObjectStore.add store "autruche" (Just 42)
@ -462,7 +462,7 @@ main = runMocha do
, onComplete: pure unit , onComplete: pure unit
} }
{ db } <- setup { db } <- setup
{ storeParams: IDBObjectStore.defaultParameters { storeParams: IDBDatabase.defaultParameters
, onUpgradeNeeded: Just $ \_ store -> launchAff' do , onUpgradeNeeded: Just $ \_ store -> launchAff' do
_ <- IDBObjectStore.openCursor store Nothing Next cb _ <- IDBObjectStore.openCursor store Nothing Next cb
_ <- IDBObjectStore.openCursor store Nothing NextUnique cb _ <- IDBObjectStore.openCursor store Nothing NextUnique cb
@ -480,7 +480,7 @@ main = runMocha do
, onComplete: pure unit , onComplete: pure unit
} }
{ db } <- setup { db } <- setup
{ storeParams: IDBObjectStore.defaultParameters { storeParams: IDBDatabase.defaultParameters
, onUpgradeNeeded: Just $ \_ store -> launchAff' do , onUpgradeNeeded: Just $ \_ store -> launchAff' do
_ <- IDBObjectStore.openKeyCursor store Nothing Next cb _ <- IDBObjectStore.openKeyCursor store Nothing Next cb
_ <- IDBObjectStore.openKeyCursor store Nothing NextUnique cb _ <- IDBObjectStore.openKeyCursor store Nothing NextUnique cb
@ -523,16 +523,16 @@ main = runMocha do
it "returns an IDBIndex and the properties are set correctly" do it "returns an IDBIndex and the properties are set correctly" do
{ db, index } <- setup { db, index } <- setup
{ storeParams : IDBObjectStore.defaultParameters { storeParams : IDBDatabase.defaultParameters
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, onUpgradeNeeded : Nothing , onUpgradeNeeded : Nothing
, keyPath : [] , keyPath : []
, values : [] , values : []
} }
IDBIndex.name index `shouldEqual` "index" IDBIndex.name index `shouldEqual` "index"
IDBIndex.keyPath index `shouldEqual` [] IDBIndex.keyPath index `shouldEqual` []
IDBIndex.unique index `shouldEqual` IDBIndex.defaultParameters.unique IDBIndex.unique index `shouldEqual` IDBObjectStore.defaultParameters.unique
IDBIndex.multiEntry index `shouldEqual` IDBIndex.defaultParameters.multiEntry IDBIndex.multiEntry index `shouldEqual` IDBObjectStore.defaultParameters.multiEntry
tearDown db tearDown db
it "attempt to create an index that requires unique values on an object store already contains duplicates" do 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
txVar <- makeVar txVar <- makeVar
dbVar <- makeVar dbVar <- makeVar
res <- attempt $ setup res <- attempt $ setup
{ storeParams : IDBObjectStore.defaultParameters { storeParams : IDBDatabase.defaultParameters
, indexParams : { unique : true , indexParams : { unique : true
, multiEntry : false , multiEntry : false
} }
@ -565,7 +565,7 @@ main = runMocha do
{ storeParams : { keyPath : ["key"] { storeParams : { keyPath : ["key"]
, autoIncrement : false , autoIncrement : false
} }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["indexedProperty"] , keyPath : ["indexedProperty"]
, values : [ { key: "key1", indexedProperty: "indexed_1" } :+: Nothing , values : [ { key: "key1", indexedProperty: "indexed_1" } :+: Nothing
, { key: "key2", indexedProperty: "indexed_2" } :+: Nothing , { key: "key2", indexedProperty: "indexed_2" } :+: Nothing
@ -579,8 +579,8 @@ main = runMocha do
it "empty keyPath" do it "empty keyPath" do
{ db } <- setup { db } <- setup
{ storeParams : IDBObjectStore.defaultParameters { storeParams : IDBDatabase.defaultParameters
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : [] , keyPath : []
, values : [ "object_1" :+: (Just $ toKey 1) , values : [ "object_1" :+: (Just $ toKey 1)
, "object_2" :+: (Just $ toKey 2) , "object_2" :+: (Just $ toKey 2)
@ -598,7 +598,7 @@ main = runMocha do
{ storeParams : { keyPath: ["key"] { storeParams : { keyPath: ["key"]
, autoIncrement: false , autoIncrement: false
} }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["i"] , keyPath : ["i"]
, values : [ { key: "date", i: (toKey date) } :+: Nothing , values : [ { key: "date", i: (toKey date) } :+: Nothing
] ]
@ -614,7 +614,7 @@ main = runMocha do
{ storeParams : { keyPath: ["key"] { storeParams : { keyPath: ["key"]
, autoIncrement: false , autoIncrement: false
} }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["i"] , keyPath : ["i"]
, values : [ { key: "num", i: (toKey num) } :+: Nothing , values : [ { key: "num", i: (toKey num) } :+: Nothing
] ]
@ -630,7 +630,7 @@ main = runMocha do
{ storeParams : { keyPath: ["key"] { storeParams : { keyPath: ["key"]
, autoIncrement: false , autoIncrement: false
} }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["i"] , keyPath : ["i"]
, values : [ { key: "array", i: (toKey array) } :+: Nothing , values : [ { key: "array", i: (toKey array) } :+: Nothing
] ]
@ -643,7 +643,7 @@ main = runMocha do
it "openKeyCursor() - throw InvalidStateError on index deleted by aborted upgrade" do it "openKeyCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
res <- attempt $ setup res <- attempt $ setup
{ storeParams : { keyPath: ["key"], autoIncrement: false } { storeParams : { keyPath: ["key"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["indexedProperty"] , keyPath : ["indexedProperty"]
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
] ]
@ -668,7 +668,7 @@ main = runMocha do
it "openKeyCursor() - throw TransactionInactiveError on aborted transaction" do it "openKeyCursor() - throw TransactionInactiveError on aborted transaction" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["key"], autoIncrement: false } { storeParams : { keyPath: ["key"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["indexedProperty"] , keyPath : ["indexedProperty"]
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
] ]
@ -694,7 +694,7 @@ main = runMocha do
it "openKeyCursor() - throw InvalidStateError when the index is deleted" do it "openKeyCursor() - throw InvalidStateError when the index is deleted" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["key"], autoIncrement: false } { storeParams : { keyPath: ["key"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["indexedProperty"] , keyPath : ["indexedProperty"]
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
] ]
@ -717,7 +717,7 @@ main = runMocha do
it "openCursor() - throw InvalidStateError on index deleted by aborted upgrade" do it "openCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
res <- attempt $ setup res <- attempt $ setup
{ storeParams : { keyPath: ["key"], autoIncrement: false } { storeParams : { keyPath: ["key"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["indexedProperty"] , keyPath : ["indexedProperty"]
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
] ]
@ -742,7 +742,7 @@ main = runMocha do
it "openCursor() - throw TransactionInactiveError on aborted transaction" do it "openCursor() - throw TransactionInactiveError on aborted transaction" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["key"], autoIncrement: false } { storeParams : { keyPath: ["key"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["indexedProperty"] , keyPath : ["indexedProperty"]
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
] ]
@ -768,7 +768,7 @@ main = runMocha do
it "openCursor() - throw InvalidStateError when the index is deleted" do it "openCursor() - throw InvalidStateError when the index is deleted" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["key"], autoIncrement: false } { storeParams : { keyPath: ["key"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["indexedProperty"] , keyPath : ["indexedProperty"]
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
] ]
@ -790,7 +790,7 @@ main = runMocha do
it "getKey() - multiEntry - adding keys" do it "getKey() - multiEntry - adding keys" do
{ db } <- setup { db } <- setup
{ storeParams : IDBObjectStore.defaultParameters { storeParams : IDBDatabase.defaultParameters
, indexParams : { unique: false, multiEntry: true } , indexParams : { unique: false, multiEntry: true }
, keyPath : ["name"] , keyPath : ["name"]
, values : [ { name: ["patate", "autruche"] } :+: (Just $ toKey 1) , values : [ { name: ["patate", "autruche"] } :+: (Just $ toKey 1)
@ -812,7 +812,7 @@ main = runMocha do
it "get() - returns the record with the first key in the range" do it "get() - returns the record with the first key in the range" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["key"], autoIncrement: false } { storeParams : { keyPath: ["key"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : ["indexedProperty"] , keyPath : ["indexedProperty"]
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing , values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
, { key: 42, indexedProperty: "autruche" } :+: Nothing , { key: 42, indexedProperty: "autruche" } :+: Nothing
@ -860,8 +860,8 @@ main = runMocha do
it "continue() - iterate to the next record" do it "continue() - iterate to the next record" do
{ db } <- setup { db } <- setup
{ storeParams : IDBObjectStore.defaultParameters { storeParams : IDBDatabase.defaultParameters
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : [] , keyPath : []
, values : [ "cupcake" :+: (Just $ toKey 4) , values : [ "cupcake" :+: (Just $ toKey 4)
, "pancake" :+: (Just $ toKey 2) , "pancake" :+: (Just $ toKey 2)
@ -899,8 +899,8 @@ main = runMocha do
it "continue() - attempt to iterate in the wrong direction" do it "continue() - attempt to iterate in the wrong direction" do
{ db } <- setup { db } <- setup
{ storeParams : IDBObjectStore.defaultParameters { storeParams : IDBDatabase.defaultParameters
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : [] , keyPath : []
, values : [ "cupcake" :+: (Just $ toKey 4) , values : [ "cupcake" :+: (Just $ toKey 4)
, "pancake" :+: (Just $ toKey 2) , "pancake" :+: (Just $ toKey 2)
@ -936,7 +936,7 @@ main = runMocha do
it "advance() - iterate cursor number of times specified by count" do it "advance() - iterate cursor number of times specified by count" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["pKey"], autoIncrement: false } { storeParams : { keyPath: ["pKey"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : [] , keyPath : []
, values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
, { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing , { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing
@ -975,7 +975,7 @@ main = runMocha do
it "delete() - remove a record from the object store" do it "delete() - remove a record from the object store" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["pKey"], autoIncrement: false } { storeParams : { keyPath: ["pKey"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : [] , keyPath : []
, values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
, { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing , { pKey: "pkey_1", iKey: "ikey_1" } :+: Nothing
@ -1009,7 +1009,7 @@ main = runMocha do
it "update() - modify a record in the object store" do it "update() - modify a record in the object store" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["pKey"], autoIncrement: false } { storeParams : { keyPath: ["pKey"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : [] , keyPath : []
, values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
] ]
@ -1041,7 +1041,7 @@ main = runMocha do
it "update() - throw ReadOnlyError after update on ReadOnly transaction" do it "update() - throw ReadOnlyError after update on ReadOnly transaction" do
{ db } <- setup { db } <- setup
{ storeParams : { keyPath: ["pKey"], autoIncrement: false } { storeParams : { keyPath: ["pKey"], autoIncrement: false }
, indexParams : IDBIndex.defaultParameters , indexParams : IDBObjectStore.defaultParameters
, keyPath : [] , keyPath : []
, values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing , values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
] ]