@@ -11,6 +11,45 @@ package org.scalajs.dom.raw
11
11
12
12
import scala .scalajs .js
13
13
import scala .scalajs .js .annotation ._
14
+ import scala .scalajs .js .|
15
+
16
+ /**
17
+ * IndexedDB transaction mode
18
+ * Provides constants for IDB Transaction modes
19
+ * These constants have been removed from browser support
20
+ * and replaced by String values
21
+ */
22
+ @ js.native
23
+ sealed trait IDBTransactionMode extends js.Any
24
+
25
+ object IDBTransactionMode {
26
+
27
+ /**
28
+ * Allows data to be read but not changed.
29
+ * It is the default transaction mode.
30
+ *
31
+ * MDN
32
+ */
33
+ val READ_ONLY = " readonly" .asInstanceOf [IDBTransactionMode ]
34
+
35
+ /**
36
+ * Allows any operation to be performed, including ones that delete and create object
37
+ * stores and indexes. This mode is for updating the version number of transactions
38
+ * that were started using the setVersion() method of IDBDatabase objects.
39
+ * Transactions of this mode cannot run concurrently with other transactions.
40
+ *
41
+ * MDN
42
+ */
43
+ val VERSION_CHANGE = " versionchange" .asInstanceOf [IDBTransactionMode ]
44
+
45
+ /**
46
+ * Allows reading and writing of data in existing data stores to be changed.
47
+ *
48
+ * MDN
49
+ */
50
+ val READ_WRITE = " readwrite" .asInstanceOf [IDBTransactionMode ]
51
+
52
+ }
14
53
15
54
/**
16
55
* The IDBObjectStore interface of the IndexedDB API represents an object store in
@@ -86,8 +125,25 @@ class IDBObjectStore extends js.Object {
86
125
*/
87
126
def put (value : js.Any , key : js.Any = js.native): IDBRequest = js.native
88
127
89
- def openCursor (range : js.Any = js.native,
90
- direction : String = js.native): IDBRequest = js.native
128
+ /**
129
+ * The method sets the position of the cursor to the appropriate record,
130
+ * based on the specified direction.
131
+ *
132
+ * MDN
133
+ */
134
+ def openCursor (range : js.UndefOr [IDBKeyRange | js.Any ] = js.undefined,
135
+ direction : js.UndefOr [
136
+ IDBCursorDirection ] = js.undefined): IDBRequest = js.native
137
+
138
+ /**
139
+ * The method sets the position of the cursor to the appropriate key,
140
+ * based on the specified direction.
141
+ *
142
+ * MDN
143
+ */
144
+ def openKeyCursor (range : js.UndefOr [IDBKeyRange | js.Any ] = js.undefined,
145
+ direction : js.UndefOr [
146
+ IDBCursorDirection ] = js.undefined): IDBRequest = js.native
91
147
92
148
/**
93
149
* Note that this method must be called only from a VersionChange transaction mode
@@ -113,6 +169,32 @@ class IDBObjectStore extends js.Object {
113
169
*/
114
170
def get (key : js.Any ): IDBRequest = js.native
115
171
172
+ /**
173
+ * If a value is successfully found, then a structured clone of it is created and set as
174
+ * the result of the request object.
175
+ *
176
+ * MDN
177
+ */
178
+ def getAll (query : js.UndefOr [IDBKeyRange | js.Any ] = js.undefined,
179
+ count : js.UndefOr [Int ] = js.undefined): IDBRequest = js.native
180
+
181
+ /**
182
+ * If a value is successfully found, then a structured clone of it is created and set as
183
+ * the result of the request object.
184
+ *
185
+ * MDN
186
+ */
187
+ def getAllKeys (query : js.UndefOr [IDBKeyRange | js.Any ] = js.undefined,
188
+ count : js.UndefOr [Int ] = js.undefined): IDBRequest = js.native
189
+
190
+ /**
191
+ * If a value is successfully found, then a structured clone of it is created and set as
192
+ * the result of the request object.
193
+ *
194
+ * MDN
195
+ */
196
+ def getKey (key : js.Any ): IDBRequest = js.native
197
+
116
198
/**
117
199
* returns an IDBRequest object, and, in a separate thread, deletes the current
118
200
* object store.
@@ -228,7 +310,7 @@ class IDBIndex extends js.Object {
228
310
* MDN
229
311
*/
230
312
def openKeyCursor (range : IDBKeyRange = js.native,
231
- direction : String = js.native): IDBRequest = js.native
313
+ direction : IDBCursorDirection = js.native): IDBRequest = js.native
232
314
233
315
/**
234
316
* Returns an IDBRequest object, and, in a separate thread, finds either the value in
@@ -246,7 +328,7 @@ class IDBIndex extends js.Object {
246
328
* MDN
247
329
*/
248
330
def openCursor (range : IDBKeyRange = js.native,
249
- direction : String = js.native): IDBRequest = js.native
331
+ direction : IDBCursorDirection = js.native): IDBRequest = js.native
250
332
}
251
333
252
334
/**
@@ -280,7 +362,7 @@ class IDBCursor extends js.Object {
280
362
*
281
363
* MDN
282
364
*/
283
- def direction : String = js.native
365
+ def direction : IDBCursorDirection = js.native
284
366
285
367
/**
286
368
* Returns the key for the record at the cursor's position. If the cursor is outside its
@@ -334,13 +416,45 @@ class IDBCursor extends js.Object {
334
416
}
335
417
336
418
@ js.native
337
- @ JSGlobal
338
- object IDBCursor extends js.Object {
419
+ sealed trait IDBCursorDirection extends js.Any
420
+
421
+ object IDBCursorDirection {
422
+
423
+ /**
424
+ * The cursor shows all records, including duplicates.
425
+ * It starts at the upper bound of the key range and moves downwards
426
+ * (monotonically decreasing in the order of keys).
427
+ *
428
+ * MDN
429
+ */
430
+ val PREV = " prev" .asInstanceOf [IDBCursorDirection ]
339
431
340
- val PREV : String = js.native
341
- val PREV_NO_DUPLICATE : String = js.native
342
- val NEXT : String = js.native
343
- val NEXT_NO_DUPLICATE : String = js.native
432
+ /**
433
+ * The cursor shows all records, excluding duplicates.
434
+ * If multiple records exist with the same key, only the first one iterated is retrieved.
435
+ * It starts at the upper bound of the key range and moves downwards.
436
+ *
437
+ * MDN
438
+ */
439
+ val PREV_UNIQUE = " prevunique" .asInstanceOf [IDBCursorDirection ]
440
+
441
+ /**
442
+ * The cursor shows all records, including duplicates.
443
+ * It starts at the lower bound of the key range and moves upwards
444
+ * (monotonically increasing in the order of keys).
445
+ *
446
+ * MDN
447
+ */
448
+ val NEXT = " next" .asInstanceOf [IDBCursorDirection ]
449
+
450
+ /**
451
+ * The cursor shows all records, excluding duplicates.
452
+ * If multiple records exist with the same key, only the first one iterated is retrieved.
453
+ * It starts at the lower bound of the key range and moves upwards.
454
+ *
455
+ * MDN
456
+ */
457
+ val NEXT_UNIQUE = " nextunique" .asInstanceOf [IDBCursorDirection ]
344
458
}
345
459
346
460
/**
@@ -493,7 +607,7 @@ class IDBTransaction extends EventTarget {
493
607
*
494
608
* MDN
495
609
*/
496
- def mode : String = js.native
610
+ def mode : IDBTransactionMode = js.native
497
611
498
612
/**
499
613
* Returns a DOMException indicating the type of error that occured when there is an
@@ -537,35 +651,6 @@ class IDBTransaction extends EventTarget {
537
651
def objectStore (name : String ): IDBObjectStore = js.native
538
652
}
539
653
540
- @ js.native
541
- @ JSGlobal
542
- object IDBTransaction extends js.Object {
543
-
544
- /**
545
- * Allows data to be read but not changed.
546
- *
547
- * MDN
548
- */
549
- val READ_ONLY : String = js.native
550
-
551
- /**
552
- * Allows any operation to be performed, including ones that delete and create object
553
- * stores and indexes. This mode is for updating the version number of transactions
554
- * that were started using the setVersion() method of IDBDatabase objects.
555
- * Transactions of this mode cannot run concurrently with other transactions.
556
- *
557
- * MDN
558
- */
559
- val VERSION_CHANGE : String = js.native
560
-
561
- /**
562
- * Allows reading and writing of data in existing data stores to be changed.
563
- *
564
- * MDN
565
- */
566
- val READ_WRITE : String = js.native
567
- }
568
-
569
654
/**
570
655
* The IDBDatabase interface of the IndexedDB API provides asynchronous access
571
656
* to a connection to a database. Use it to create, manipulate, and delete
@@ -652,7 +737,7 @@ class IDBDatabase extends EventTarget {
652
737
* MDN
653
738
*/
654
739
def transaction (storeNames : js.Any ,
655
- mode : String = js.native): IDBTransaction = js.native
740
+ mode : IDBTransactionMode = js.native): IDBTransaction = js.native
656
741
657
742
/**
658
743
* As with createObjectStore, this method can be called only within a versionchange
0 commit comments