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
@@ -1104,7 +1108,7 @@ They will return true if any transactions were cleaned up, or false otherwise.
1104
1108
1. For each [=/transaction=] |transaction| with [=transaction/cleanup event loop=]
1105
1109
matching the current [=/event loop=]:
1106
1110
1107
-
1. Set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
1111
+
1. If |transaction|'s [=transaction/manual commit flag=] is false, then set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
@@ -2625,9 +2702,13 @@ instance on which it was called.
2625
2702
Returns a new [=/transaction=] with the given
2626
2703
|scope| (which can be a single [=/object store=][=object-store/name=] or an array of [=object-store/names=]),
2627
2704
|mode| ({{"readonly"}} or {{"readwrite"}}),
2628
-
and additional |options| including {{IDBTransactionOptions/durability}} ({{"default"}}, {{"strict"}} or {{"relaxed"}}).
2705
+
and additional |options| including
2706
+
{{IDBTransactionOptions/manualCommit}} (true or false), and
2707
+
{{IDBTransactionOptions/durability}} ({{"default"}}, {{"strict"}} or {{"relaxed"}}).
2629
2708
2630
-
The default |mode| is {{"readonly"}} and the default {{IDBTransactionOptions/durability}} is {{"default"}}.
2709
+
The default |mode| is {{"readonly"}}.
2710
+
The default {{IDBTransactionOptions/manualCommit}} is false.
2711
+
The default {{IDBTransactionOptions/durability}} is {{"default"}}.
2631
2712
2632
2713
: |connection| . {{IDBDatabase/close()|close}}()
2633
2714
::
@@ -2658,7 +2739,11 @@ The <dfn method for=IDBDatabase>transaction(|storeNames|, |mode|, |options|)</df
2658
2739
1. If |mode| is not {{"readonly"}} or {{"readwrite"}},
2659
2740
[=throw=] a [=TypeError=].
2660
2741
2661
-
1. Let |transaction| be a newly [=transaction/created=][=/transaction=] with this [=/connection=], |mode|, |options|' {{IDBTransactionOptions/durability}} member, and the set of [=/object stores=] named in |scope|.
2742
+
1. Let |transaction| be a newly [=transaction/created=][=/transaction=] with this [=/connection=], |mode|, and the set of [=/object stores=] named in |scope|.
2743
+
2744
+
1. Set |transaction|'s [=transaction/manual commit flag=] to |options|'{{IDBTransactionOptions/manualCommit}} member.
2745
+
2746
+
1. Set |transaction|'s [=transaction/durability hint=] to |options|'{{IDBTransactionOptions/durability}} member.
2662
2747
2663
2748
1. Set |transaction|'s [=transaction/cleanup event loop=] to the
2664
2749
current [=/event loop=].
@@ -2667,6 +2752,12 @@ The <dfn method for=IDBDatabase>transaction(|storeNames|, |mode|, |options|)</df
2667
2752
2668
2753
</div>
2669
2754
2755
+
<aside class=advisement>
2756
+
🚧
2757
+
The {{IDBTransactionOptions/manualCommit}} option is new in this edition.
2758
+
🚧
2759
+
</aside>
2760
+
2670
2761
<aside class=advisement>
2671
2762
🚧
2672
2763
The {{IDBTransactionOptions/durability}} option is new in this edition.
@@ -4717,6 +4808,7 @@ the contents of the database.
The <dfn method for=IDBTransaction>commit()</dfn> method steps are:
4896
5002
4897
-
1. If [=/this=]'s [=transaction/state=] is not [=transaction/active=],
5003
+
1. If [=/this=]'s [=transaction/manual commit flag=] is false,
5004
+
and [=/this=]'s [=transaction/state=] is not [=transaction/active=],
4898
5005
then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.
4899
5006
4900
5007
1. Run [=commit a transaction=] with [=/this=].
@@ -5155,7 +5262,7 @@ To <dfn>commit a transaction</dfn> with the |transaction| to commit, run these s
5155
5262
<aside class=note>
5156
5263
Even if an exception is thrown from one of the event handlers of
5157
5264
this event, the transaction is still committed since writing the
5158
-
database changes happens before the event takes places. Only
5265
+
database changes happens before the event takes place. Only
5159
5266
after the transaction has been successfully written is the
5160
5267
<a event>`complete`</a> event fired.
5161
5268
</aside>
@@ -5484,14 +5591,14 @@ To <dfn>fire a success event</dfn> at a |request|, run these steps:
5484
5591
1. If |transaction|'s [=transaction/state=] is [=transaction/active=],
5485
5592
then:
5486
5593
5487
-
1. Set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
5594
+
1. If |transaction|'s [=transaction/manual commit flag=] is false, then set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
5488
5595
5489
5596
1. If |legacyOutputDidListenersThrowFlag| is true,
5490
5597
then run [=abort a transaction=] with
5491
5598
|transaction| and a newly <a for=exception>created</a>
5492
5599
"{{AbortError}}" {{DOMException}}.
5493
5600
5494
-
1. If |transaction|'s [=transaction/request list=] is empty,
5601
+
1. If |transaction|'s [=transaction/manual commit flag=] is false and if |transaction|'s [=transaction/request list=] is empty,
5495
5602
then run [=commit a transaction=] with |transaction|.
5496
5603
5497
5604
</div>
@@ -5523,7 +5630,7 @@ To <dfn>fire an error event</dfn> at a |request|, run these steps:
5523
5630
1. If |transaction|'s [=transaction/state=] is [=transaction/active=],
5524
5631
then:
5525
5632
5526
-
1. Set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
5633
+
1. If |transaction|'s [=transaction/manual commit flag=] is false, then set |transaction|'s [=transaction/state=] to [=transaction/inactive=].
5527
5634
5528
5635
1. If |legacyOutputDidListenersThrowFlag| is true,
5529
5636
then run [=abort a transaction=] with
@@ -5544,7 +5651,7 @@ To <dfn>fire an error event</dfn> at a |request|, run these steps:
5544
5651
|transaction| and [=/request=]'s [=request/error=], and
5545
5652
terminate these steps.
5546
5653
5547
-
1. If |transaction|'s [=transaction/request list=] is empty,
5654
+
1. If |transaction|'s [=transaction/manual commit flag=] is false and |transaction|'s [=transaction/request list=] is empty,
5548
5655
then run [=commit a transaction=] with |transaction|.
5549
5656
5550
5657
</div>
@@ -6784,6 +6891,7 @@ For the revision history of the second edition, see [that document's Revision Hi
6784
6891
* Added {{IDBTransactionOptions/durability}} option and {{IDBTransaction/durability}} attribute. ([Issue #50](https://github.com/w3c/IndexedDB/issues/50))
6785
6892
* 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