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|.
2923
+
2924
+
[=/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 [=in-line keys=]. Otherwise, a "{{DataError}}" {{DOMException}} will be thrown.
2925
+
2926
+
2927
+
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.
2934
+
2935
+
This method can only be used with an [=/object store=] that uses [=out-of-line keys=]. Otherwise, a "{{DataError}}" {{DOMException}} will be thrown.
2936
+
2937
+
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}}.
2938
+
2939
+
2917
2940
: |request| = |store| .
2918
2941
{{IDBObjectStore/delete()|delete}}(|query|)
2919
2942
::
@@ -2932,13 +2955,13 @@ and false otherwise.
2932
2955
</div>
2933
2956
2934
2957
2935
-
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.
2958
+
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.
2936
2959
2937
-
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.
2960
+
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.
2938
2961
2939
2962
<div algorithm>
2940
2963
2941
-
To <dfn>add or put</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|, run these steps:
2964
+
To <dfn>add or put a single record</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|, run these steps:
2942
2965
2943
2966
1. Let |transaction| be |handle|'s
2944
2967
[=object-store-handle/transaction=].
@@ -3009,6 +3032,119 @@ To <dfn>add or put</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|,
3009
3032
3010
3033
1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with |handle| and |operation|.
3011
3034
3035
+
</div>
3036
+
3037
+
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.
3038
+
3039
+
<div algorithm>
3040
+
3041
+
The <dfn method for=IDBObjectStore>putAllEntries(|entries|)</dfn> method steps are:
3042
+
3043
+
1. Let |keys| be a new [=/list=].
3044
+
3045
+
1. Let |values| be a new [=/list=].
3046
+
3047
+
1. [=list/For each=] |entry| of |entries|:
3048
+
3049
+
1. If |entry|'s [=list/size=] is not 2, [=throw=] a [=TypeError=].
3050
+
3051
+
1. [=list/Append=] |entry|[0] to |keys|.
3052
+
3053
+
Note: Keys are not [=convert a value to a key|converted=] until a subsequent step.
3054
+
3055
+
1. [=list/Append=] |entry|[1] to |values|.
3056
+
3057
+
1. Return the result of running [=add or put multiple records=] with [=/this=], |values|, false, and |keys|.
3058
+
3059
+
</div>
3060
+
3061
+
<div algorithm>
3062
+
3063
+
To <dfn>add or put multiple records</dfn> with |handle|, |values|, |no-overwrite flag|, and optional |keys|, run these steps:
3064
+
3065
+
1. [=/Assert=]: If |keys| is given, |values| [=list/size=] equals |keys| [=list/size=].
3066
+
3067
+
1. Let |transaction| be |handle|'s
3068
+
[=object-store-handle/transaction=].
3069
+
3070
+
1. Let |store| be |handle|'s
3071
+
[=object-store-handle/object store=].
3072
+
3073
+
1. If |store| has been deleted,
3074
+
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
3075
+
3076
+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=],
3077
+
then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
3078
+
3079
+
1. If |transaction| is a [=read-only transaction=],
3080
+
[=throw=] a "{{ReadOnlyError}}" {{DOMException}}.
3081
+
3082
+
1. If |store| uses [=in-line keys=] and |keys| were given,
3083
+
[=throw=] a "{{DataError}}" {{DOMException}}.
3084
+
3085
+
1. If |store| uses [=out-of-line keys=] and has no [=key
3086
+
generator=] and |keys| were not given, [=throw=] a
3087
+
"{{DataError}}" {{DOMException}}.
3088
+
3089
+
1. If |keys| were given, then:
3090
+
3091
+
1. Let |rs| be a new [=/list=].
3092
+
3093
+
1. [=list/For each=] |key| of |keys|:
3094
+
3095
+
1. Let |r| be the result of [=/converting a value to a key=] with |key|. Rethrow any exceptions.
3096
+
3097
+
1. If |r| is invalid, [=throw=] a "{{DataError}}" {{DOMException}}.
3098
+
3099
+
1. [=list/Append=] |r| to |rs|.
3100
+
3101
+
1. Let |keys| be |rs|.
3102
+
3103
+
1. Let |targetRealm| be a user-agent defined [=Realm=].
3104
+
3105
+
1. Let |clones| be a new [=/list=].
3106
+
3107
+
1. [=list/For each=] |value| of |values|:
3108
+
3109
+
1. Let |clone| be a [=clone=] of |value| in |targetRealm| during |transaction|.
3110
+
Rethrow any exceptions.
3111
+
3112
+
<details class=note>
3113
+
<summary>Why create a copy of the value?</summary>
3114
+
The value is serialized when stored. Treating it as a copy
3115
+
here allows other algorithms in this specification to treat it as
3116
+
an ECMAScript value, but implementations can optimize this
3117
+
if the difference in behavior is not observable.
3118
+
</details>
3119
+
3120
+
1. [=list/Append=] |clone| to |clones|.
3121
+
3122
+
1. If |store| uses [=in-line keys=], then:
3123
+
3124
+
1. Let |keys| be a new [=/list=].
3125
+
3126
+
1. [=list/For each=] |clone| of |clones|:
3127
+
3128
+
1. Let |key| be undefined.
3129
+
3130
+
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.
3131
+
3132
+
1. If |kpk| is invalid, [=throw=] a "{{DataError}}" {{DOMException}}.
3133
+
3134
+
1. If |kpk| is not failure, let |key| be |kpk|.
3135
+
3136
+
1. Otherwise (|kpk| is failure):
3137
+
3138
+
1. If |store| does not have a [=key generator=], [=throw=] a "{{DataError}}" {{DOMException}}.
3139
+
3140
+
1. Otherwise, if [=check that a key could be injected into a value=] with |clone| and |store|'s [=object-store/key path=] return false, [=throw=] a "{{DataError}}" {{DOMException}}.
3141
+
3142
+
1. [=list/Append=] |key| to |keys|.
3143
+
3144
+
1. Let |operation| be an algorithm to run [=store multiple records into an object store=] with |store|, |clones|, |keys|, and |no-overwrite flag|.
3145
+
3146
+
1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with |handle| and |operation|.
3147
+
3012
3148
3013
3149
</div>
3014
3150
@@ -5714,6 +5850,25 @@ To <dfn>store a record into an object store</dfn> with
5714
5850
5715
5851
</div>
5716
5852
5853
+
<div algorithm>
5854
+
5855
+
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}
@@ -6801,6 +6956,7 @@ For the revision history of the second edition, see [that document's Revision Hi
6801
6956
* 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