-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathIDBObjectStore.res
More file actions
178 lines (146 loc) · 6.79 KB
/
Copy pathIDBObjectStore.res
File metadata and controls
178 lines (146 loc) · 6.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/**
Adds or updates a record in store with the given value and key.
If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.
If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.
If successful, request's result will be the record's key.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/put)
*/
@send
external put: (
IndexedDbTypes.idbObjectStore,
~value: JSON.t,
~key: IndexedDbTypes.idbValidKey=?,
) => IndexedDbTypes.idbRequest<IndexedDbTypes.idbValidKey> = "put"
/**
Adds or updates a record in store with the given value and key.
If the store uses in-line keys and key is specified a "DataError" DOMException will be thrown.
If put() is used, any existing record with the key will be replaced. If add() is used, and if a record with the key already exists the request will fail, with request's error set to a "ConstraintError" DOMException.
If successful, request's result will be the record's key.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/add)
*/
@send
external add: (
IndexedDbTypes.idbObjectStore,
~value: JSON.t,
~key: IndexedDbTypes.idbValidKey=?,
) => IndexedDbTypes.idbRequest<IndexedDbTypes.idbValidKey> = "add"
/**
Deletes records in store with the given key or in the given key range in query.
If successful, request's result will be undefined.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/delete)
*/
@send
external delete: (IndexedDbTypes.idbObjectStore, unknown) => IndexedDbTypes.idbRequest<unit> =
"delete"
/**
Deletes all records in store.
If successful, request's result will be undefined.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/clear)
*/
@send
external clear: IndexedDbTypes.idbObjectStore => IndexedDbTypes.idbRequest<unit> = "clear"
/**
Retrieves the value of the first record matching the given key or key range in query.
If successful, request's result will be the value, or undefined if there was no matching record.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/get)
*/
@send
external get: (IndexedDbTypes.idbObjectStore, unknown) => IndexedDbTypes.idbRequest<JSON.t> = "get"
/**
Retrieves the key of the first record matching the given key or key range in query.
If successful, request's result will be the key, or undefined if there was no matching record.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/getKey)
*/
@send
external getKey: (IndexedDbTypes.idbObjectStore, unknown) => IndexedDbTypes.idbRequest<unknown> =
"getKey"
/**
Retrieves the values of the records matching the given key or key range in query (up to count if given).
If successful, request's result will be an Array of the values.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/getAll)
*/
@send
external getAll: (
IndexedDbTypes.idbObjectStore,
~query: unknown=?,
~count: int=?,
) => IndexedDbTypes.idbRequest<array<JSON.t>> = "getAll"
/**
Retrieves the keys of records matching the given key or key range in query (up to count if given).
If successful, request's result will be an Array of the keys.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/getAllKeys)
*/
@send
external getAllKeys: (
IndexedDbTypes.idbObjectStore,
~query: unknown=?,
~count: int=?,
) => IndexedDbTypes.idbRequest<array<IndexedDbTypes.idbValidKey>> = "getAllKeys"
/**
Retrieves the number of records matching the given key or key range in query.
If successful, request's result will be the count.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/count)
*/
@send
external count: (
IndexedDbTypes.idbObjectStore,
~query: unknown=?,
) => IndexedDbTypes.idbRequest<int> = "count"
/**
Opens a cursor over the records matching query, ordered by direction. If query is null, all records in store are matched.
If successful, request's result will be an IDBCursorWithValue pointing at the first matching record, or null if there were no matching records.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/openCursor)
*/
@send
external openCursor: (
IndexedDbTypes.idbObjectStore,
~query: unknown=?,
~direction: IndexedDbTypes.idbCursorDirection=?,
) => IndexedDbTypes.idbRequest<unknown> = "openCursor"
/**
Opens a cursor with key only flag set over the records matching query, ordered by direction. If query is null, all records in store are matched.
If successful, request's result will be an IDBCursor pointing at the first matching record, or null if there were no matching records.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/openKeyCursor)
*/
@send
external openKeyCursor: (
IndexedDbTypes.idbObjectStore,
~query: unknown=?,
~direction: IndexedDbTypes.idbCursorDirection=?,
) => IndexedDbTypes.idbRequest<unknown> = "openKeyCursor"
/**
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/index)
*/
@send
external index: (IndexedDbTypes.idbObjectStore, string) => IndexedDbTypes.idbIndex = "index"
/**
Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.
Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/createIndex)
*/
@send
external createIndex: (
IndexedDbTypes.idbObjectStore,
~name: string,
~keyPath: string,
~options: IndexedDbTypes.idbIndexParameters=?,
) => IndexedDbTypes.idbIndex = "createIndex"
/**
Creates a new index in store with the given name, keyPath and options and returns a new IDBIndex. If the keyPath and options define constraints that cannot be satisfied with the data already in store the upgrade transaction will abort with a "ConstraintError" DOMException.
Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/createIndex)
*/
@send
external createIndex2: (
IndexedDbTypes.idbObjectStore,
~name: string,
~keyPath: array<string>,
~options: IndexedDbTypes.idbIndexParameters=?,
) => IndexedDbTypes.idbIndex = "createIndex"
/**
Deletes the index in store with the given name.
Throws an "InvalidStateError" DOMException if not called within an upgrade transaction.
[Read more on MDN](https://developer.mozilla.org/docs/Web/API/IDBObjectStore/deleteIndex)
*/
@send
external deleteIndex: (IndexedDbTypes.idbObjectStore, string) => unit = "deleteIndex"