@@ -1,10 +1,13 @@
11module Database.IndexedDB.IDBObjectStore
22 ( class IDBObjectStore, add, clear, createIndex, delete, deleteIndex, index, put
33 , module Database.IndexedDB.IDBIndex.Internal
4+ , IDBObjectStoreParameters
5+ , IndexName
46 , autoIncrement
57 , indexNames
68 , keyPath
79 , name
10+ , defaultParameters
811 ) where
912
1013import Prelude (Unit, ($), (<$>))
@@ -18,8 +21,8 @@ import Data.Function.Uncurried (Fn2, Fn3, Fn4)
1821import Data.Maybe (Maybe)
1922import Data.Nullable (Nullable, toNullable)
2023
21−import Database.IndexedDB.Core (INDEXED_DB, Index, KeyRange, ObjectStore)
22−import Database.IndexedDB.IDBIndex.Internal (class IDBIndex, count, get, getAllKeys, getKey, openCursor, openKeyCursor)
24+import Database.IndexedDB.Core (INDEXED_DB, Index, KeyRange, KeyPath, ObjectStore)
25+import Database.IndexedDB.IDBIndex.Internal (class IDBIndex, IDBIndexParameters, count, get, getAllKeys, getKey, openCursor, openKeyCursor)
2326import Database.IndexedDB.IDBKey.Internal (Key(Key), extractForeign)
2427
2528
@@ -29,13 +32,22 @@ import Database.IndexedDB.IDBKey.Internal (Key(Key), extractForeign)
2932class IDBObjectStore store where
3033 add :: forall value eff. store -> value -> Maybe Key -> Aff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Key
3134 clear :: forall eff. store -> Aff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Unit
32− createIndex :: forall eff. store -> String -> (Array String) -> { unique :: Boolean, multiEntry :: Boolean } -> Eff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Index
35+ createIndex :: forall eff. store -> IndexName -> KeyPath -> IDBIndexParameters -> Eff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Index
3336 delete :: forall eff. store -> KeyRange -> Aff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Unit
34− deleteIndex :: forall eff. store -> String -> Eff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Unit
35− index :: forall eff. store -> String -> Eff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Index
37+ deleteIndex :: forall eff. store -> IndexName -> Eff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Unit
38+ index :: forall eff. store -> IndexName -> Eff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Index
3639 put :: forall value eff. store -> value -> Maybe Key -> Aff (idb :: INDEXED_DB, exception :: EXCEPTION | eff) Key
3740
3841
42+type IndexName = String
43+
44+
45+type IDBObjectStoreParameters =
46+ { keyPath :: KeyPath
47+ , autoIncrement :: Boolean
48+ }
49+
50+
3951--------------------
4052-- ATTRIBUTES
4153--
@@ -85,6 +97,13 @@ instance idbObjectStoreObjectStore :: IDBObjectStore ObjectStore where
8597 Key <$> Fn.runFn3 _put store value (toNullable $ extractForeign <$> key)
8698
8799
100+defaultParameters :: IDBObjectStoreParameters
101+defaultParameters =
102+ { keyPath : []
103+ , autoIncrement : false
104+ }
105+
106+
88107--------------------
89108-- FFI
90109--