git.iko.soy/purescript-indexed-DB
on master help sign in
change class method indentations
commit9197f3697d9645fc8a7b3eaad78d020c086e3983 authorKtorZ <matthias.benkort@gmail.com> dateFri 7 Jul 2017, 11:39 (9 years ago) parent5f9f341
3 files changed+71−15
src/Database/IndexedDB/IDBDatabase.purs+22−4 src/Database/IndexedDB/IDBObjectStore.purs+38−7 src/Database/IndexedDB/IDBTransaction.purs+11−4
src/Database/IndexedDB/IDBDatabase.purs+22−4
@@ -30,23 +30,41 @@ import Database.IndexedDB.IDBObjectStore (IDBObjectStoreParameters)
3030-- | The IDBDatabase interface represents a connection to a database.
3131class IDBDatabase db where
3232 -- | Closes the connection once all running transactions have finished.
33− close :: forall e. db -> Aff (idb :: IDB | e) Unit
33+ close
34+ :: forall e
35+ . db
36+ -> Aff (idb :: IDB | e) Unit
3437
3538 -- | Creates a new object store with the given name and options and returns a new IDBObjectStore.
3639 -- |
3740 -- | Throws a "InvalidStateError" DOMException if not called within an upgrade transaction
38− createObjectStore :: forall e. db -> StoreName -> IDBObjectStoreParameters -> Aff (idb :: IDB | e) ObjectStore
41+ createObjectStore
42+ :: forall e
43+ . db
44+ -> StoreName
45+ -> IDBObjectStoreParameters
46+ -> Aff (idb :: IDB | e) ObjectStore
3947
4048 -- | Deletes the object store with the given name.
4149 -- |
4250 -- | Throws a "InvalidStateError" DOMException if not called within an upgrade transaction.
43− deleteObjectStore :: forall e. db -> StoreName -> Aff (idb :: IDB | e) ObjectStore
51+ deleteObjectStore
52+ :: forall e
53+ . db
54+ -> StoreName
55+ -> Aff (idb :: IDB | e) ObjectStore
4456
4557 -- | Returns a new transaction with the given mode (ReadOnly|ReadWrite)
4658 -- | and scope which in the form of an array of object store names.
47− transaction :: forall e. db -> Array StoreName -> TransactionMode -> Aff (idb :: IDB | e) Transaction
59+ transaction
60+ :: forall e
61+ . db
62+ -> Array StoreName
63+ -> TransactionMode
64+ -> Aff (idb :: IDB | e) Transaction
4865
4966
67+-- | Type alias for StoreName
5068type StoreName = String
5169
5270
src/Database/IndexedDB/IDBObjectStore.purs+38−7
@@ -38,10 +38,18 @@ class IDBObjectStore store where
3838 -- |
3939 -- | If add() is used, and if a record with the key already exists the request will fail,
4040 -- | with a "ConstraintError" DOMException.
41− add :: forall v k e. (IDBKey k) => store -> v -> Maybe k -> Aff (idb :: IDB | e) Key
41+ add
42+ :: forall v k e. (IDBKey k)
43+ => store
44+ -> v
45+ -> Maybe k
46+ -> Aff (idb :: IDB | e) Key
4247
4348 -- | Deletes all records in store.
44− clear :: forall e. store -> Aff (idb :: IDB | e) Unit
49+ clear
50+ :: forall e
51+ . store
52+ -> Aff (idb :: IDB | e) Unit
4553
4654 -- | Creates a new index in store with the given name, keyPath and options and
4755 -- | returns a new IDBIndex. If the keyPath and options define constraints that
@@ -49,18 +57,36 @@ class IDBObjectStore store where
4957 -- | will abort with a "ConstraintError" DOMException.
5058 -- |
5159 -- | Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
52− createIndex :: forall e. store -> IndexName -> KeyPath -> IDBIndexParameters -> Aff (idb :: IDB | e) Index
60+ createIndex
61+ :: forall e
62+ . store
63+ -> IndexName
64+ -> KeyPath
65+ -> IDBIndexParameters
66+ -> Aff (idb :: IDB | e) Index
5367
5468 -- | Deletes records in store with the given key or in the given key range in query.
55− delete :: forall e. store -> KeyRange -> Aff (idb :: IDB | e) Unit
69+ delete
70+ :: forall e
71+ . store
72+ -> KeyRange
73+ -> Aff (idb :: IDB | e) Unit
5674
5775 -- | Deletes the index in store with the given name.
5876 -- |
5977 -- | Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
60− deleteIndex :: forall e. store -> IndexName -> Aff (idb :: IDB | e) Unit
78+ deleteIndex
79+ :: forall e
80+ . store
81+ -> IndexName
82+ -> Aff (idb :: IDB | e) Unit
6183
6284 -- | Returns an IDBIndex for the index named name in store.
63− index :: forall e. store -> IndexName -> Aff (idb :: IDB | e) Index
85+ index
86+ :: forall e
87+ . store
88+ -> IndexName
89+ -> Aff (idb :: IDB | e) Index
6490
6591 -- | Adds or updates a record in store with the given value and key.
6692 -- |
@@ -68,7 +94,12 @@ class IDBObjectStore store where
6894 -- | will be thrown.
6995 -- |
7096 -- | If put() is used, any existing record with the key will be replaced.
71− put :: forall v k e. (IDBKey k) => store -> v -> Maybe k -> Aff (idb :: IDB | e) Key
97+ put
98+ :: forall v k e. (IDBKey k)
99+ => store
100+ -> v
101+ -> Maybe k
102+ -> Aff (idb :: IDB | e) Key
72103
73104
74105-- | Type alias for IndexName
src/Database/IndexedDB/IDBTransaction.purs+11−4
@@ -29,10 +29,17 @@ import Database.IndexedDB.Core (IDB, Database, ObjectStore, Transaction, Tra
2929class IDBTransaction tx where
3030 -- | Aborts the transaction. All pending requests will fail with a "AbortError"
3131 -- | DOMException and all changes made to the database will be reverted.
32− abort :: forall e. tx -> Aff (idb :: IDB | e) Unit
32+ abort
33+ :: forall e
34+ . tx
35+ -> Aff (idb :: IDB | e) Unit
3336
3437 -- | Returns an IDBObjectStore in the transaction's scope.
35− objectStore :: forall e. tx -> String -> Aff (idb :: IDB | e) ObjectStore
38+ objectStore
39+ :: forall e
40+ . tx
41+ -> String
42+ -> Aff (idb :: IDB | e) ObjectStore
3643
3744
3845--------------------
@@ -99,8 +106,8 @@ onError
99106 . Transaction
100107 -> (Error -> Eff ( | e') Unit)
101108 -> Aff (idb :: IDB | e) Unit
102−onError db f =
103− Fn.runFn2 _onError db f
109+onError db' f =
110+ Fn.runFn2 _onError db' f
104111
105112
106113--------------------