You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A [=/transaction=] has an <dfn>manual commit flag</dfn>, which is initially false. By default, transactions commit automatically when all outstanding requests have been processed. This can be behavior can be modified by options set when creating the transaction.
938
+
937
939
A [=/transaction=] has a <dfn>durability hint</dfn>. This is a hint to the user agent of whether to prioritize performance or durability when committing the transaction. The [=transaction/durability hint=] is one of the following:
938
940
939
941
: {{"strict"}}
@@ -1041,10 +1043,11 @@ The <dfn>lifetime</dfn> of a
1041
1043
</aside>
1042
1044
1043
1045
1. When each [=/request=] associated with a transaction is [=request/processed=],
1044
-
a <a event>`success`</a> or <a event>`error`</a>[=event=] will be
1045
-
fired. While the event is being [=dispatched=], the transaction
1046
+
a <a event>`success`</a> or <a event>`error`</a>[=event=] will be fired.
1047
+
If the transaction's [=transaction/manual commit flag=] is false (the default), then
1048
+
while the event is being [=dispatched=], the transaction
1046
1049
[=transaction/state=] is set to [=transaction/active=], allowing
1047
-
additional requests to be made against the transaction. Once the
1050
+
additional requests to be made against the transaction; once the
1048
1051
event dispatch is complete, the transaction's
1049
1052
[=transaction/state=] is set to [=transaction/inactive=] again.
1050
1053
@@ -1063,11 +1066,12 @@ The <dfn>lifetime</dfn> of a
1063
1066
[=/object stores=] as well as additions and removals of [=/object
1064
1067
stores=] and [=/indexes=].
1065
1068
1066
-
1. The implementation must attempt to <dfn lt="commit|committed">commit</dfn>
1067
-
a transaction when all [=/requests=] placed against the
1069
+
1. If a transaction's [=transaction/manual commit flag=] is false, then
1070
+
the implementation must attempt to <dfn lt="commit|committed">commit</dfn>
1071
+
it when all [=/requests=] placed against the
1068
1072
transaction have completed and their returned results handled, no
1069
1073
new requests have been placed against the transaction, and the
1070
-
transaction has not been [=transaction/aborted=]
1074
+
transaction has not been [=transaction/aborted=].
1071
1075
1072
1076
An explicit call to {{IDBTransaction/commit()}} will initiate a
1073
1077
[=transaction/commit=] without waiting for request results to be
@@ -1103,7 +1107,7 @@ They will return true if any transactions were cleaned up, or false otherwise.
1103
1107
1. For each [=/transaction=] |transaction| with [=transaction/cleanup event loop=]
1104
1108
matching the current [=/event loop=]:
1105
1109
1106
-
1. Set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
1110
+
1. If |transaction|'s [=transaction/manual commit flag=] is false, then set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
@@ -2624,9 +2701,13 @@ instance on which it was called.
2624
2701
Returns a new [=/transaction=] with the given
2625
2702
|scope| (which can be a single [=/object store=][=object-store/name=] or an array of [=object-store/names=]),
2626
2703
|mode| ({{"readonly"}} or {{"readwrite"}}),
2627
-
and additional |options| including {{IDBTransactionOptions/durability}} ({{"default"}}, {{"strict"}} or {{"relaxed"}}).
2704
+
and additional |options| including
2705
+
{{IDBTransactionOptions/manualCommit}} (true or false), and
2706
+
{{IDBTransactionOptions/durability}} ({{"default"}}, {{"strict"}} or {{"relaxed"}}).
2628
2707
2629
-
The default |mode| is {{"readonly"}} and the default {{IDBTransactionOptions/durability}} is {{"default"}}.
2708
+
The default |mode| is {{"readonly"}}.
2709
+
The default {{IDBTransactionOptions/manualCommit}} is false.
2710
+
The default {{IDBTransactionOptions/durability}} is {{"default"}}.
2630
2711
2631
2712
: |connection| . {{IDBDatabase/close()|close}}()
2632
2713
::
@@ -2657,7 +2738,11 @@ The <dfn method for=IDBDatabase>transaction(|storeNames|, |mode|, |options|)</df
2657
2738
1. If |mode| is not {{"readonly"}} or {{"readwrite"}},
2658
2739
[=throw=] a [=TypeError=].
2659
2740
2660
-
1. Let |transaction| be a newly [=transaction/created=][=/transaction=] with |connection|, |mode|, |options|' {{IDBTransactionOptions/durability}} member, and the set of [=/object stores=] named in |scope|.
2741
+
1. Let |transaction| be a newly [=transaction/created=][=/transaction=] with |connection|, |mode|, and the set of [=/object stores=] named in |scope|.
2742
+
2743
+
1. Set |transaction|'s [=transaction/manual commit flag=] to |options|'{{IDBTransactionOptions/manualCommit}} member.
2744
+
2745
+
1. Set |transaction|'s [=transaction/durability hint=] to |options|'{{IDBTransactionOptions/durability}} member.
2661
2746
2662
2747
1. Set |transaction|'s [=transaction/cleanup event loop=] to the
2663
2748
current [=/event loop=].
@@ -2666,6 +2751,12 @@ The <dfn method for=IDBDatabase>transaction(|storeNames|, |mode|, |options|)</df
2666
2751
2667
2752
</div>
2668
2753
2754
+
<aside class=advisement>
2755
+
🚧
2756
+
The {{IDBTransactionOptions/manualCommit}} option is new in this edition.
2757
+
🚧
2758
+
</aside>
2759
+
2669
2760
<aside class=advisement>
2670
2761
🚧
2671
2762
The {{IDBTransactionOptions/durability}} option is new in this edition.
@@ -4732,6 +4823,7 @@ the contents of the database.
The <dfn method for=IDBTransaction>commit()</dfn> method steps are:
4910
5016
4911
-
1. If [=/this=]'s [=transaction/state=] is not [=transaction/active=],
5017
+
1. If [=/this=]'s [=transaction/manual commit flag=] is false,
5018
+
and [=/this=]'s [=transaction/state=] is not [=transaction/active=],
4912
5019
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4913
5020
4914
5021
1. Run [=commit a transaction=] with [=/this=].
@@ -5169,7 +5276,7 @@ To <dfn>commit a transaction</dfn> with the |transaction| to commit, run these s
5169
5276
<aside class=note>
5170
5277
Even if an exception is thrown from one of the event handlers of
5171
5278
this event, the transaction is still committed since writing the
5172
-
database changes happens before the event takes places. Only
5279
+
database changes happens before the event takes place. Only
5173
5280
after the transaction has been successfully written is the
5174
5281
<a event>`complete`</a> event fired.
5175
5282
</aside>
@@ -5499,14 +5606,14 @@ To <dfn>fire a success event</dfn> at a |request|, run these steps:
5499
5606
1. If |transaction|'s [=transaction/state=] is [=transaction/active=],
5500
5607
then:
5501
5608
5502
-
1. Set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
5609
+
1. If |transaction|'s [=transaction/manual commit flag=] is false, then set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
5503
5610
5504
5611
1. If |legacyOutputDidListenersThrowFlag| is true,
5505
5612
then run [=abort a transaction=] with
5506
5613
|transaction| and a newly <a for=exception>created</a>
5507
5614
"{{AbortError}}" {{DOMException}}.
5508
5615
5509
-
1. If |transaction|'s [=transaction/request list=] is empty,
5616
+
1. If |transaction|'s [=transaction/manual commit flag=] is false and if |transaction|'s [=transaction/request list=] is empty,
5510
5617
then run [=commit a transaction=] with |transaction|.
5511
5618
5512
5619
</div>
@@ -5538,7 +5645,7 @@ To <dfn>fire an error event</dfn> at a |request|, run these steps:
5538
5645
1. If |transaction|'s [=transaction/state=] is [=transaction/active=],
5539
5646
then:
5540
5647
5541
-
1. Set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
5648
+
1. If |transaction|'s [=transaction/manual commit flag=] is false, then set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
5542
5649
5543
5650
1. If |legacyOutputDidListenersThrowFlag| is true,
5544
5651
then run [=abort a transaction=] with
@@ -5559,7 +5666,7 @@ To <dfn>fire an error event</dfn> at a |request|, run these steps:
5559
5666
|transaction| and [=/request=]'s [=request/error=], and
5560
5667
terminate these steps.
5561
5668
5562
-
1. If |transaction|'s [=transaction/request list=] is empty,
5669
+
1. If |transaction|'s [=transaction/manual commit flag=] is false and |transaction|'s [=transaction/request list=] is empty,
5563
5670
then run [=commit a transaction=] with |transaction|.
5564
5671
5565
5672
</div>
@@ -6777,6 +6884,7 @@ For the revision history of the second edition, see [that document's Revision Hi
6777
6884
* Transactions are now temporarily made inactive during clone operations.
6778
6885
* Added {{IDBTransactionOptions/durability}} option and {{IDBTransaction/durability}} attribute. ([Issue #50](https://github.com/w3c/IndexedDB/issues/50))
6779
6886
* Specified [[#transaction-scheduling]] more precisely and disallow starting read/write transactions while read-only transactions with overlapping scope are running. ([Issue #253](https://github.com/w3c/IndexedDB/issues/253))
0 commit comments