mirror of
https://github.com/ilyakooo0/purescript-indexedDB.git
synced 2024-09-11 06:55:48 +03:00
make Key a complete opaque type
This commit is contained in:
parent
3b53339870
commit
24fa04adcb
@ -27,7 +27,7 @@ import Data.Nullable (Nullable, toNullable)
|
||||
import Data.String.Read (read)
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ continue
|
||||
-> Maybe k
|
||||
-> Aff (idb :: IDB | e) Unit
|
||||
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.
|
||||
@ -63,7 +63,7 @@ continuePrimaryKey
|
||||
-> k
|
||||
-> Aff (idb :: IDB | e) Unit
|
||||
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.
|
||||
@ -80,12 +80,12 @@ delete =
|
||||
-- | Throws a "DataError" DOMException if the effective object store uses
|
||||
-- | in-line keys and the key would have changed.
|
||||
update
|
||||
:: forall val e cursor key. (IDBCursor cursor) => (IDBKey key)
|
||||
:: forall val e cursor. (IDBCursor cursor)
|
||||
=> cursor
|
||||
-> val
|
||||
-> Aff (idb :: IDB | e) key
|
||||
-> Aff (idb :: IDB | e) Key
|
||||
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
|
||||
-- | if the cursor is advancing or is finished.
|
||||
key
|
||||
:: forall e cursor key. (IDBConcreteCursor cursor) => (IDBKey key)
|
||||
:: forall e cursor. (IDBConcreteCursor cursor)
|
||||
=> cursor
|
||||
-> Aff (idb :: IDB | e) key
|
||||
-> Aff (idb :: IDB | e) Key
|
||||
key =
|
||||
_key
|
||||
_key >>> map toKey
|
||||
|
||||
|
||||
-- | Returns the effective key of the cursor. Throws a "InvalidStateError" DOMException
|
||||
-- | if the cursor is advancing or is finished.
|
||||
primaryKey
|
||||
:: forall e cursor key. (IDBConcreteCursor cursor) => (IDBKey key)
|
||||
:: forall e cursor. (IDBConcreteCursor cursor)
|
||||
=> cursor
|
||||
-> Aff (idb :: IDB | e) key
|
||||
-> Aff (idb :: IDB | e) Key
|
||||
primaryKey =
|
||||
_primaryKey
|
||||
_primaryKey >>> map toKey
|
||||
|
||||
|
||||
-- | Returns the IDBObjectStore or IDBIndex the cursor was opened from.
|
||||
@ -169,15 +169,15 @@ foreign import _direction
|
||||
|
||||
|
||||
foreign import _key
|
||||
:: forall cursor e key. (IDBKey key)
|
||||
=> cursor
|
||||
-> Aff (idb :: IDB | e) key
|
||||
:: forall cursor e
|
||||
. cursor
|
||||
-> Aff (idb :: IDB | e) Key
|
||||
|
||||
|
||||
foreign import _primaryKey
|
||||
:: forall cursor e key. (IDBKey key)
|
||||
=> cursor
|
||||
-> Aff (idb :: IDB | e) key
|
||||
:: forall cursor e
|
||||
. cursor
|
||||
-> Aff (idb :: IDB | e) Key
|
||||
|
||||
|
||||
foreign import _source
|
||||
@ -186,8 +186,8 @@ foreign import _source
|
||||
|
||||
|
||||
foreign import _update
|
||||
:: forall cursor e key. (IDBKey key)
|
||||
=> Fn2 cursor Foreign (Aff (idb :: IDB | e) key)
|
||||
:: forall cursor e
|
||||
. Fn2 cursor Foreign (Aff (idb :: IDB | e) Foreign)
|
||||
|
||||
|
||||
foreign import _value
|
||||
|
@ -32,7 +32,7 @@ import Data.Maybe (Maybe)
|
||||
import Data.Nullable (Nullable, toMaybe, toNullable)
|
||||
|
||||
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
|
||||
-- | (up to the number given if given).
|
||||
getAllKeys
|
||||
:: forall e index key. (IDBIndex index) => (IDBKey key)
|
||||
:: forall e index. (IDBIndex index)
|
||||
=> index
|
||||
-> Maybe KeyRange
|
||||
-> Maybe Int
|
||||
-> Aff (idb :: IDB | e) (Array key)
|
||||
-> Aff (idb :: IDB | e) (Array Key)
|
||||
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.
|
||||
getKey
|
||||
:: forall e index key. (IDBIndex index) => (IDBKey key)
|
||||
:: forall e index. (IDBIndex index)
|
||||
=> index
|
||||
-> KeyRange
|
||||
-> Aff (idb :: IDB | e) (Maybe key)
|
||||
-> Aff (idb :: IDB | e) (Maybe Key)
|
||||
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.
|
||||
@ -204,13 +204,13 @@ foreign import _get
|
||||
|
||||
|
||||
foreign import _getAllKeys
|
||||
:: forall index e k. (IDBKey k)
|
||||
=> Fn3 index (Nullable KeyRange) (Nullable Int) (Aff (idb :: IDB | e) (Array k))
|
||||
:: forall index e
|
||||
. Fn3 index (Nullable KeyRange) (Nullable Int) (Aff (idb :: IDB | e) (Array Foreign))
|
||||
|
||||
|
||||
foreign import _getKey
|
||||
:: forall index e k. (IDBKey k)
|
||||
=> Fn2 index KeyRange (Aff (idb :: IDB | e) (Nullable k))
|
||||
:: forall index e
|
||||
. Fn2 index KeyRange (Aff (idb :: IDB | e) (Nullable Foreign))
|
||||
|
||||
|
||||
foreign import _openCursor
|
||||
|
@ -5,7 +5,6 @@ module Database.IndexedDB.IDBKey.Internal
|
||||
( Key
|
||||
, class IDBKey, toKey , fromKey , unsafeFromKey
|
||||
, none
|
||||
, toForeign
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
@ -33,13 +32,6 @@ import Data.Traversable (traverse)
|
||||
newtype Key = Key Foreign
|
||||
|
||||
|
||||
toForeign
|
||||
:: Key
|
||||
-> Foreign
|
||||
toForeign (Key f) =
|
||||
f
|
||||
|
||||
|
||||
--------------------
|
||||
-- INTERFACES
|
||||
--
|
||||
@ -115,6 +107,12 @@ instance idbKeyKey :: IDBKey Key where
|
||||
unsafeFromKey = id
|
||||
|
||||
|
||||
instance idbKeyForeign :: IDBKey Foreign where
|
||||
toKey = Key
|
||||
fromKey (Key f) = pure f
|
||||
unsafeFromKey (Key f) = f
|
||||
|
||||
|
||||
instance idbKeyInt :: IDBKey Int where
|
||||
toKey = Foreign.toForeign >>> Key
|
||||
fromKey (Key f) = Foreign.readInt f
|
||||
|
@ -19,7 +19,7 @@ module Database.IndexedDB.IDBKeyRange
|
||||
, upperOpen
|
||||
) where
|
||||
|
||||
import Prelude (($), (>>>))
|
||||
import Prelude (($), (>>>), map)
|
||||
|
||||
import Data.Foreign (Foreign)
|
||||
import Data.Function.Uncurried as Fn
|
||||
@ -28,7 +28,7 @@ import Data.Maybe (Maybe)
|
||||
import Data.Nullable (Nullable, toMaybe)
|
||||
|
||||
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
|
||||
-> KeyRange
|
||||
only key =
|
||||
_only (toForeign $ toKey key)
|
||||
_only (unsafeFromKey $ toKey key)
|
||||
|
||||
|
||||
-- | Returns a new IDBKeyRange starting at key with no upper bound.
|
||||
@ -60,7 +60,7 @@ lowerBound
|
||||
-> Open
|
||||
-> KeyRange
|
||||
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.
|
||||
@ -71,7 +71,7 @@ upperBound
|
||||
-> Open
|
||||
-> KeyRange
|
||||
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`.
|
||||
@ -80,12 +80,12 @@ upperBound key open =
|
||||
-- |
|
||||
-- | It throws a `DataError` if the bound is invalid.
|
||||
bound
|
||||
:: forall a. (IDBKey a)
|
||||
=> { lower :: a, upper :: a, lowerOpen :: Boolean, upperOpen :: Boolean }
|
||||
:: forall key. (IDBKey key)
|
||||
=> { lower :: key, upper :: key, lowerOpen :: Boolean, upperOpen :: Boolean }
|
||||
-> Maybe KeyRange
|
||||
bound { lower: key1, upper: key2, lowerOpen: open1, upperOpen: open2 } =
|
||||
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.
|
||||
includes
|
||||
:: forall k range. (IDBKey k) => (IDBKeyRange range)
|
||||
:: forall key range. (IDBKey key) => (IDBKeyRange range)
|
||||
=> range
|
||||
-> k
|
||||
-> key
|
||||
-> Boolean
|
||||
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.
|
||||
lower
|
||||
:: forall key. (IDBKey key)
|
||||
=> KeyRange
|
||||
-> Maybe key
|
||||
:: KeyRange
|
||||
-> Maybe Key
|
||||
lower =
|
||||
_lower >>> toMaybe
|
||||
_lower >>> toMaybe >>> map toKey
|
||||
|
||||
|
||||
-- | Returns upper bound if any.
|
||||
upper
|
||||
:: forall key. (IDBKey key)
|
||||
=> KeyRange
|
||||
-> Maybe key
|
||||
:: KeyRange
|
||||
-> Maybe Key
|
||||
upper =
|
||||
_upper >>> toMaybe
|
||||
_upper >>> toMaybe >>> map toKey
|
||||
|
||||
|
||||
-- | Returns true if the lower open flag is set, false otherwise.
|
||||
@ -165,15 +163,13 @@ foreign import _includes
|
||||
|
||||
|
||||
foreign import _lower
|
||||
:: forall key. (IDBKey key)
|
||||
=> KeyRange
|
||||
-> Nullable key
|
||||
:: KeyRange
|
||||
-> Nullable Foreign
|
||||
|
||||
|
||||
foreign import _upper
|
||||
:: forall key. (IDBKey key)
|
||||
=> KeyRange
|
||||
-> Nullable key
|
||||
:: KeyRange
|
||||
-> Nullable Foreign
|
||||
|
||||
|
||||
foreign import _lowerOpen
|
||||
|
@ -36,7 +36,7 @@ import Data.Nullable (Nullable, toNullable)
|
||||
|
||||
import Database.IndexedDB.Core
|
||||
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
|
||||
@ -88,9 +88,9 @@ add
|
||||
=> store
|
||||
-> val
|
||||
-> Maybe key
|
||||
-> Aff (idb :: IDB | e) key
|
||||
-> Aff (idb :: IDB | e) 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.
|
||||
@ -162,9 +162,9 @@ put
|
||||
=> store
|
||||
-> val
|
||||
-> Maybe key
|
||||
-> Aff (idb :: IDB | e) key
|
||||
-> Aff (idb :: IDB | e) 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
|
||||
--
|
||||
foreign import _add
|
||||
:: forall e key val store. (IDBKey key)
|
||||
=> Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) key)
|
||||
:: forall e val store
|
||||
. Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) Foreign)
|
||||
|
||||
|
||||
foreign import _autoIncrement
|
||||
@ -265,8 +265,8 @@ foreign import _name
|
||||
|
||||
|
||||
foreign import _put
|
||||
:: forall e key val store. (IDBKey key)
|
||||
=> Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) key)
|
||||
:: forall e val store
|
||||
. Fn3 store val (Nullable Foreign) (Aff (idb :: IDB | e) Foreign)
|
||||
|
||||
|
||||
foreign import _transaction
|
||||
|
@ -332,7 +332,7 @@ main = runMocha do
|
||||
putVar var true
|
||||
|
||||
var <- makeVar
|
||||
{ db, store } <- setup IDBObjectStore.defaultParameters
|
||||
{ db, store } <- setup IDBDatabase.defaultParameters
|
||||
IDBDatabase.close db
|
||||
db <- IDBFactory.open "db" (Just 999) { onUpgradeNeeded : Just (onUpgradeNeeded var)
|
||||
, onBlocked : Nothing
|
||||
@ -396,7 +396,7 @@ main = runMocha do
|
||||
|
||||
it "clear()" do
|
||||
{ db } <- setup
|
||||
{ storeParams: IDBObjectStore.defaultParameters
|
||||
{ storeParams: IDBDatabase.defaultParameters
|
||||
, onUpgradeNeeded: Just $ \_ store -> launchAff' do
|
||||
key <- IDBObjectStore.add store "patate" (Just 14)
|
||||
_ <- IDBObjectStore.clear store
|
||||
@ -407,7 +407,7 @@ main = runMocha do
|
||||
|
||||
it "count()" do
|
||||
{ db } <- setup
|
||||
{ storeParams: IDBObjectStore.defaultParameters
|
||||
{ storeParams: IDBDatabase.defaultParameters
|
||||
, onUpgradeNeeded: Just $ \_ store -> launchAff' do
|
||||
key <- IDBObjectStore.add store "patate" (Just 14)
|
||||
key <- IDBObjectStore.add store "autruche" (Just 42)
|
||||
@ -418,7 +418,7 @@ main = runMocha do
|
||||
|
||||
it "getKey()" do
|
||||
{ db } <- setup
|
||||
{ storeParams: IDBObjectStore.defaultParameters
|
||||
{ storeParams: IDBDatabase.defaultParameters
|
||||
, onUpgradeNeeded: Just $ \_ store -> launchAff' do
|
||||
key <- IDBObjectStore.add store "patate" (Just 14)
|
||||
mkey <- IDBObjectStore.getKey store (IDBKeyRange.only 14)
|
||||
@ -431,7 +431,7 @@ main = runMocha do
|
||||
|
||||
it "getAllKeys()" do
|
||||
{ db } <- setup
|
||||
{ storeParams: IDBObjectStore.defaultParameters
|
||||
{ storeParams: IDBDatabase.defaultParameters
|
||||
, onUpgradeNeeded: Just $ \_ store -> launchAff' do
|
||||
key1 <- IDBObjectStore.add store "patate" (Just 14)
|
||||
key2 <- IDBObjectStore.add store "autruche" (Just 42)
|
||||
@ -462,7 +462,7 @@ main = runMocha do
|
||||
, onComplete: pure unit
|
||||
}
|
||||
{ db } <- setup
|
||||
{ storeParams: IDBObjectStore.defaultParameters
|
||||
{ storeParams: IDBDatabase.defaultParameters
|
||||
, onUpgradeNeeded: Just $ \_ store -> launchAff' do
|
||||
_ <- IDBObjectStore.openCursor store Nothing Next cb
|
||||
_ <- IDBObjectStore.openCursor store Nothing NextUnique cb
|
||||
@ -480,7 +480,7 @@ main = runMocha do
|
||||
, onComplete: pure unit
|
||||
}
|
||||
{ db } <- setup
|
||||
{ storeParams: IDBObjectStore.defaultParameters
|
||||
{ storeParams: IDBDatabase.defaultParameters
|
||||
, onUpgradeNeeded: Just $ \_ store -> launchAff' do
|
||||
_ <- IDBObjectStore.openKeyCursor store Nothing Next 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
|
||||
{ db, index } <- setup
|
||||
{ storeParams : IDBObjectStore.defaultParameters
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
{ storeParams : IDBDatabase.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, onUpgradeNeeded : Nothing
|
||||
, keyPath : []
|
||||
, values : []
|
||||
}
|
||||
IDBIndex.name index `shouldEqual` "index"
|
||||
IDBIndex.keyPath index `shouldEqual` []
|
||||
IDBIndex.unique index `shouldEqual` IDBIndex.defaultParameters.unique
|
||||
IDBIndex.multiEntry index `shouldEqual` IDBIndex.defaultParameters.multiEntry
|
||||
IDBIndex.unique index `shouldEqual` IDBObjectStore.defaultParameters.unique
|
||||
IDBIndex.multiEntry index `shouldEqual` IDBObjectStore.defaultParameters.multiEntry
|
||||
tearDown db
|
||||
|
||||
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
|
||||
dbVar <- makeVar
|
||||
res <- attempt $ setup
|
||||
{ storeParams : IDBObjectStore.defaultParameters
|
||||
{ storeParams : IDBDatabase.defaultParameters
|
||||
, indexParams : { unique : true
|
||||
, multiEntry : false
|
||||
}
|
||||
@ -565,7 +565,7 @@ main = runMocha do
|
||||
{ storeParams : { keyPath : ["key"]
|
||||
, autoIncrement : false
|
||||
}
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["indexedProperty"]
|
||||
, values : [ { key: "key1", indexedProperty: "indexed_1" } :+: Nothing
|
||||
, { key: "key2", indexedProperty: "indexed_2" } :+: Nothing
|
||||
@ -579,8 +579,8 @@ main = runMocha do
|
||||
|
||||
it "empty keyPath" do
|
||||
{ db } <- setup
|
||||
{ storeParams : IDBObjectStore.defaultParameters
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
{ storeParams : IDBDatabase.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : []
|
||||
, values : [ "object_1" :+: (Just $ toKey 1)
|
||||
, "object_2" :+: (Just $ toKey 2)
|
||||
@ -598,7 +598,7 @@ main = runMocha do
|
||||
{ storeParams : { keyPath: ["key"]
|
||||
, autoIncrement: false
|
||||
}
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["i"]
|
||||
, values : [ { key: "date", i: (toKey date) } :+: Nothing
|
||||
]
|
||||
@ -614,7 +614,7 @@ main = runMocha do
|
||||
{ storeParams : { keyPath: ["key"]
|
||||
, autoIncrement: false
|
||||
}
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["i"]
|
||||
, values : [ { key: "num", i: (toKey num) } :+: Nothing
|
||||
]
|
||||
@ -630,7 +630,7 @@ main = runMocha do
|
||||
{ storeParams : { keyPath: ["key"]
|
||||
, autoIncrement: false
|
||||
}
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["i"]
|
||||
, 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
|
||||
res <- attempt $ setup
|
||||
{ storeParams : { keyPath: ["key"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["indexedProperty"]
|
||||
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
|
||||
]
|
||||
@ -668,7 +668,7 @@ main = runMocha do
|
||||
it "openKeyCursor() - throw TransactionInactiveError on aborted transaction" do
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["key"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["indexedProperty"]
|
||||
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
|
||||
]
|
||||
@ -694,7 +694,7 @@ main = runMocha do
|
||||
it "openKeyCursor() - throw InvalidStateError when the index is deleted" do
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["key"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["indexedProperty"]
|
||||
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
|
||||
]
|
||||
@ -717,7 +717,7 @@ main = runMocha do
|
||||
it "openCursor() - throw InvalidStateError on index deleted by aborted upgrade" do
|
||||
res <- attempt $ setup
|
||||
{ storeParams : { keyPath: ["key"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["indexedProperty"]
|
||||
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
|
||||
]
|
||||
@ -742,7 +742,7 @@ main = runMocha do
|
||||
it "openCursor() - throw TransactionInactiveError on aborted transaction" do
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["key"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["indexedProperty"]
|
||||
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
|
||||
]
|
||||
@ -768,7 +768,7 @@ main = runMocha do
|
||||
it "openCursor() - throw InvalidStateError when the index is deleted" do
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["key"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["indexedProperty"]
|
||||
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
|
||||
]
|
||||
@ -790,7 +790,7 @@ main = runMocha do
|
||||
|
||||
it "getKey() - multiEntry - adding keys" do
|
||||
{ db } <- setup
|
||||
{ storeParams : IDBObjectStore.defaultParameters
|
||||
{ storeParams : IDBDatabase.defaultParameters
|
||||
, indexParams : { unique: false, multiEntry: true }
|
||||
, keyPath : ["name"]
|
||||
, 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
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["key"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : ["indexedProperty"]
|
||||
, values : [ { key: 14, indexedProperty: "patate" } :+: Nothing
|
||||
, { key: 42, indexedProperty: "autruche" } :+: Nothing
|
||||
@ -860,8 +860,8 @@ main = runMocha do
|
||||
|
||||
it "continue() - iterate to the next record" do
|
||||
{ db } <- setup
|
||||
{ storeParams : IDBObjectStore.defaultParameters
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
{ storeParams : IDBDatabase.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : []
|
||||
, values : [ "cupcake" :+: (Just $ toKey 4)
|
||||
, "pancake" :+: (Just $ toKey 2)
|
||||
@ -899,8 +899,8 @@ main = runMocha do
|
||||
|
||||
it "continue() - attempt to iterate in the wrong direction" do
|
||||
{ db } <- setup
|
||||
{ storeParams : IDBObjectStore.defaultParameters
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
{ storeParams : IDBDatabase.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : []
|
||||
, values : [ "cupcake" :+: (Just $ toKey 4)
|
||||
, "pancake" :+: (Just $ toKey 2)
|
||||
@ -936,7 +936,7 @@ main = runMocha do
|
||||
it "advance() - iterate cursor number of times specified by count" do
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["pKey"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : []
|
||||
, values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: 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
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["pKey"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : []
|
||||
, values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: 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
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["pKey"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : []
|
||||
, 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
|
||||
{ db } <- setup
|
||||
{ storeParams : { keyPath: ["pKey"], autoIncrement: false }
|
||||
, indexParams : IDBIndex.defaultParameters
|
||||
, indexParams : IDBObjectStore.defaultParameters
|
||||
, keyPath : []
|
||||
, values : [ { pKey: "pkey_0", iKey: "ikey_0" } :+: Nothing
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user