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
Adds or updates multiple [=object-store/records=] in |store| with the given array of |values|.
2927
+
2928
+
[=/Keys=] can not be explicitly specified using this method, so it can only be used with an [=/object store=] that either has a [=/key generator=] or that uses [=object-store/in-line keys=]. Otherwise, a "{{DataError}}" {{DOMException}} will be thrown.
2929
+
2930
+
2931
+
If any [=/record=] fails to be stored, no updates will be made and the |request| will fail, with |request|'s {{IDBRequest/error}} set to an error e.g. a "{{ConstraintError}}" {{DOMException}}.
Adds or updates multiple [=object-store/records=] in |store| with the given array of |entries|. Each entry is a two element array with a [=/key=] and [=/value=] for the record.
2938
+
2939
+
This method can only be used with an [=/object store=] that uses [=object-store/out-of-line keys=]. Otherwise, a "{{DataError}}" {{DOMException}} will be thrown.
2940
+
2941
+
If any [=/record=] fails to be stored, no updates will be made and the |request| will fail, with |request|'s {{IDBRequest/error}} set to an error e.g. a "{{ConstraintError}}" {{DOMException}}.
2942
+
2943
+
2921
2944
: |request| = |store| .
2922
2945
{{IDBObjectStore/delete()|delete}}(|query|)
2923
2946
::
@@ -2936,13 +2959,13 @@ and false otherwise.
2936
2959
</div>
2937
2960
2938
2961
2939
-
The <dfn method for=IDBObjectStore>put(|value|, |key|)</dfn> method steps are to return the result of running [=add or put=] with [=/this=], |value|, |key| and the |no-overwrite flag| false.
2962
+
The <dfn method for=IDBObjectStore>put(|value|, |key|)</dfn> method steps are to return the result of running [=add or put a single record=] with [=/this=], |value|, |key| and false.
2940
2963
2941
-
The <dfn method for=IDBObjectStore>add(|value|, |key|)</dfn> method steps are to return the result of running [=add or put=] with [=/this=], |value|, |key| and the |no-overwrite flag| true.
2964
+
The <dfn method for=IDBObjectStore>add(|value|, |key|)</dfn> method steps are to return the result of running [=add or put a single record=] with [=/this=], |value|, |key| and true.
2942
2965
2943
2966
<div algorithm>
2944
2967
2945
-
To <dfn>add or put</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|, run these steps:
2968
+
To <dfn>add or put a single record</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|, run these steps:
2946
2969
2947
2970
1. Let |transaction| be |handle|'s
2948
2971
[=object-store-handle/transaction=].
@@ -3013,6 +3036,119 @@ To <dfn>add or put</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|,
3013
3036
3014
3037
1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with |handle| and |operation|.
3015
3038
3039
+
</div>
3040
+
3041
+
The <dfn method for=IDBObjectStore>putAllValues(|values|)</dfn> method steps are to return the result of running [=add or put multiple records=] with [=/this=], |values|, and false.
3042
+
3043
+
<div algorithm>
3044
+
3045
+
The <dfn method for=IDBObjectStore>putAllEntries(|entries|)</dfn> method steps are:
3046
+
3047
+
1. Let |keys| be a new [=/list=].
3048
+
3049
+
1. Let |values| be a new [=/list=].
3050
+
3051
+
1. [=list/For each=] |entry| of |entries|:
3052
+
3053
+
1. If |entry|'s [=list/size=] is not 2, [=exception/throw=] a [=TypeError=].
3054
+
3055
+
1. [=list/Append=] |entry|[0] to |keys|.
3056
+
3057
+
Note: Keys are not [=convert a value to a key|converted=] until a subsequent step.
3058
+
3059
+
1. [=list/Append=] |entry|[1] to |values|.
3060
+
3061
+
1. Return the result of running [=add or put multiple records=] with [=/this=], |values|, false, and |keys|.
3062
+
3063
+
</div>
3064
+
3065
+
<div algorithm>
3066
+
3067
+
To <dfn>add or put multiple records</dfn> with |handle|, |values|, |no-overwrite flag|, and optional |keys|, run these steps:
3068
+
3069
+
1. [=/Assert=]: If |keys| is given, |values| [=list/size=] equals |keys| [=list/size=].
3070
+
3071
+
1. Let |transaction| be |handle|'s
3072
+
[=object-store-handle/transaction=].
3073
+
3074
+
1. Let |store| be |handle|'s
3075
+
[=object-store-handle/object store=].
3076
+
3077
+
1. If |store| has been deleted,
3078
+
[=exception/throw=] an "{{InvalidStateError}}" {{DOMException}}.
3079
+
3080
+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=],
3081
+
then [=exception/throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
3082
+
3083
+
1. If |transaction| is a [=transaction/read-only transaction=],
3084
+
[=exception/throw=] a "{{ReadOnlyError}}" {{DOMException}}.
3085
+
3086
+
1. If |store| uses [=object-store/in-line keys=] and |keys| were given,
3087
+
[=exception/throw=] a "{{DataError}}" {{DOMException}}.
3088
+
3089
+
1. If |store| uses [=object-store/out-of-line keys=] and has no [=key
3090
+
generator=] and |keys| were not given, [=exception/throw=] a
3091
+
"{{DataError}}" {{DOMException}}.
3092
+
3093
+
1. If |keys| were given, then:
3094
+
3095
+
1. Let |rs| be a new [=/list=].
3096
+
3097
+
1. [=list/For each=] |key| of |keys|:
3098
+
3099
+
1. Let |r| be the result of [=/converting a value to a key=] with |key|. Rethrow any exceptions.
3100
+
3101
+
1. If |r| is invalid, [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3102
+
3103
+
1. [=list/Append=] |r| to |rs|.
3104
+
3105
+
1. Let |keys| be |rs|.
3106
+
3107
+
1. Let |targetRealm| be a user-agent defined [=Realm=].
3108
+
3109
+
1. Let |clones| be a new [=/list=].
3110
+
3111
+
1. [=list/For each=] |value| of |values|:
3112
+
3113
+
1. Let |clone| be a [=clone=] of |value| in |targetRealm| during |transaction|.
3114
+
Rethrow any exceptions.
3115
+
3116
+
<details class=note>
3117
+
<summary>Why create a copy of the value?</summary>
3118
+
The value is serialized when stored. Treating it as a copy
3119
+
here allows other algorithms in this specification to treat it as
3120
+
an ECMAScript value, but implementations can optimize this
3121
+
if the difference in behavior is not observable.
3122
+
</details>
3123
+
3124
+
1. [=list/Append=] |clone| to |clones|.
3125
+
3126
+
1. If |store| uses [=object-store/in-line keys=], then:
3127
+
3128
+
1. Let |keys| be a new [=/list=].
3129
+
3130
+
1. [=list/For each=] |clone| of |clones|:
3131
+
3132
+
1. Let |key| be undefined.
3133
+
3134
+
1. Let |kpk| be the result of [=/extracting a key from a value using a key path=] with |clone| and |store|'s [=object-store/key path=]. Rethrow any exceptions.
3135
+
3136
+
1. If |kpk| is invalid, [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3137
+
3138
+
1. If |kpk| is not failure, let |key| be |kpk|.
3139
+
3140
+
1. Otherwise (|kpk| is failure):
3141
+
3142
+
1. If |store| does not have a [=key generator=], [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3143
+
3144
+
1. Otherwise, if [=check that a key could be injected into a value=] with |clone| and |store|'s [=object-store/key path=] return false, [=exception/throw=] a "{{DataError}}" {{DOMException}}.
3145
+
3146
+
1. [=list/Append=] |key| to |keys|.
3147
+
3148
+
1. Let |operation| be an algorithm to run [=store multiple records into an object store=] with |store|, |clones|, |keys|, and |no-overwrite flag|.
3149
+
3150
+
1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with |handle| and |operation|.
3151
+
3016
3152
3017
3153
</div>
3018
3154
@@ -5718,6 +5854,25 @@ To <dfn>store a record into an object store</dfn> with
5718
5854
5719
5855
</div>
5720
5856
5857
+
<div algorithm>
5858
+
5859
+
To <dfn>store multiple records into an object store</dfn> with |store|, |values|, |keys|, and a |no-overwrite flag|, run these steps:
## Object store retrieval operations ## {#object-store-retrieval-operation}
@@ -6805,6 +6960,7 @@ For the revision history of the second edition, see [that document's Revision Hi
6805
6960
* 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