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
Copy file name to clipboardExpand all lines: index.bs
+114-3Lines changed: 114 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -2911,13 +2911,13 @@ and false otherwise.
2911
2911
</div>
2912
2912
2913
2913
2914
-
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.
2914
+
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 the |no-overwrite flag| false.
2915
2915
2916
-
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.
2916
+
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 the |no-overwrite flag| true.
2917
2917
2918
2918
<div algorithm>
2919
2919
2920
-
To <dfn>add or put</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|, run these steps:
2920
+
To <dfn>add or put a single record</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|, run these steps:
2921
2921
2922
2922
1. Let |transaction| be |handle|'s
2923
2923
[=object-store-handle/transaction=].
@@ -2988,6 +2988,98 @@ To <dfn>add or put</dfn> with |handle|, |value|, |key|, and |no-overwrite flag|,
2988
2988
2989
2989
1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with |handle| and |operation|.
2990
2990
2991
+
</div>
2992
+
2993
+
2994
+
Issue: Define `putAll()` method(s) that use [=/add or put multiple records=].
2995
+
2996
+
<div algorithm>
2997
+
2998
+
To <dfn>add or put multiple records</dfn> with |handle|, |values|, |keys|, and |no-overwrite flag|, run these steps:
2999
+
3000
+
1. [=/Assert=]: If |keys| is given, |values| [=list/size=] equals |keys| [=list/size=].
3001
+
3002
+
1. Let |transaction| be |handle|'s
3003
+
[=object-store-handle/transaction=].
3004
+
3005
+
1. Let |store| be |handle|'s
3006
+
[=object-store-handle/object store=].
3007
+
3008
+
1. If |store| has been deleted,
3009
+
[=throw=] an "{{InvalidStateError}}" {{DOMException}}.
3010
+
3011
+
1. If |transaction|'s [=transaction/state=] is not [=transaction/active=],
3012
+
then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.
3013
+
3014
+
1. If |transaction| is a [=read-only transaction=],
3015
+
[=throw=] a "{{ReadOnlyError}}" {{DOMException}}.
3016
+
3017
+
1. If |store| uses [=in-line keys=] and |keys| were given,
3018
+
[=throw=] a "{{DataError}}" {{DOMException}}.
3019
+
3020
+
1. If |store| uses [=out-of-line keys=] and has no [=key
3021
+
generator=] and |keys| were not given, [=throw=] a
3022
+
"{{DataError}}" {{DOMException}}.
3023
+
3024
+
1. If |keys| were given, then:
3025
+
3026
+
1. Let |rs| be a new [=/list=].
3027
+
3028
+
1. [=list/For each=] |key| of |keys|:
3029
+
3030
+
1. Let |r| be the result of running [=convert a value to a key=] with |key|. Rethrow any exceptions.
3031
+
3032
+
1. If |r| is invalid, [=throw=] a "{{DataError}}" {{DOMException}}.
3033
+
3034
+
1. [=list/Append=] |r| to |rs|.
3035
+
3036
+
1. Let |keys| be |rs|.
3037
+
3038
+
1. Let |targetRealm| be a user-agent defined [=Realm=].
3039
+
3040
+
1. Let |clones| be a new [=/list=].
3041
+
3042
+
1. [=list/For each=] |value| of |values|:
3043
+
3044
+
1. Let |clone| be a [=clone=] of |value| in |targetRealm| during |transaction|.
3045
+
Rethrow any exceptions.
3046
+
3047
+
<details class=note>
3048
+
<summary>Why create a copy of the value?</summary>
3049
+
The value is serialized when stored. Treating it as a copy
3050
+
here allows other algorithms in this specification to treat it as
3051
+
an ECMAScript value, but implementations can optimize this
3052
+
if the difference in behavior is not observable.
3053
+
</details>
3054
+
3055
+
1. [=list/Append=] |clone| to |clones|.
3056
+
3057
+
1. If |store| uses [=in-line keys=], then:
3058
+
3059
+
1. Let |keys| be a new [=/list=].
3060
+
3061
+
1. [=list/For each=] |clone| of |clones|:
3062
+
3063
+
1. Let |key| be undefined.
3064
+
3065
+
1. Let |kpk| be the result of running [=extract a key from a value using a key path=] with |clone| and |store|'s [=object-store/key path=]. Rethrow any exceptions.
3066
+
3067
+
1. If |kpk| is invalid, [=throw=] a "{{DataError}}" {{DOMException}}.
3068
+
3069
+
1. If |kpk| is not failure, let |key| be |kpk|.
3070
+
3071
+
1. Otherwise (|kpk| is failure):
3072
+
3073
+
1. If |store| does not have a [=key generator=], [=throw=] a "{{DataError}}" {{DOMException}}.
3074
+
3075
+
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}}.
3076
+
3077
+
1. [=list/Append=] |key| to |keys|.
3078
+
3079
+
1. Let |operation| be an algorithm to run [=store multiple records into an object store=] with |store|, |clones|, |keys|, and |no-overwrite flag|.
3080
+
3081
+
1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with |handle| and |operation|.
3082
+
2991
3083
2992
3084
</div>
2993
3085
@@ -5698,6 +5790,25 @@ To <dfn>store a record into an object store</dfn> with
5698
5790
5699
5791
</div>
5700
5792
5793
+
<div algorithm>
5794
+
5795
+
To <dfn>store multiple records into an object store</dfn> with |store|, |values|, |keys|, and a |no-overwrite flag|, run these steps:
0 commit comments