Skip to content

Commit db057c6

Browse files
Sketch out putAllXXX methods
1 parent be18ab3 commit db057c6

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

index.bs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,6 +2720,8 @@ interface IDBObjectStore {
27202720
readonly attribute boolean autoIncrement;
27212721

27222722
[NewObject] IDBRequest put(any value, optional any key);
2723+
[NewObject] IDBRequest putAllValues(sequence<any> values);
2724+
[NewObject] IDBRequest putAllEntries(sequence<sequence<any>> entries);
27232725
[NewObject] IDBRequest add(any value, optional any key);
27242726
[NewObject] IDBRequest delete(any query);
27252727
[NewObject] IDBRequest clear();
@@ -2893,6 +2895,27 @@ and false otherwise.
28932895
If successful, |request|'s {{IDBRequest/result}} will be the
28942896
[=object-store/record=]'s [=/key=].
28952897

2898+
: |request| = |store| . {{IDBObjectStore/putAllValues()|putAllValues}}(|values|)
2899+
2900+
::
2901+
Adds or updates multiple [=object-store/records=] in |store| with the given array of |values|.
2902+
2903+
[=/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.
2904+
2905+
2906+
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}}.
2907+
2908+
2909+
: |request| = |store| . {{IDBObjectStore/putAllEntries()|putAllEntries}}(|entries|)
2910+
2911+
::
2912+
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.
2913+
2914+
This method can only be used with an [=/object store=] that uses [=out-of-line keys=]. Otherwise, a "{{DataError}}" {{DOMException}} will be thrown.
2915+
2916+
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}}.
2917+
2918+
28962919
: |request| = |store| .
28972920
{{IDBObjectStore/delete()|delete}}(|query|)
28982921
::
@@ -2911,9 +2934,9 @@ and false otherwise.
29112934
</div>
29122935

29132936

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.
2937+
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.
29152938

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.
2939+
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.
29172940

29182941
<div algorithm>
29192942

@@ -2990,12 +3013,33 @@ To <dfn>add or put a single record</dfn> with |handle|, |value|, |key|, and |no-
29903013

29913014
</div>
29923015

3016+
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.
29933017

2994-
Issue: Define `putAll()` method(s) that use [=/add or put multiple records=].
3018+
<div algorithm>
3019+
3020+
The <dfn method for=IDBObjectStore>putAllEntries(|entries|)</dfn> method steps are:
3021+
3022+
1. Let |keys| be a new [=/list=].
3023+
3024+
1. Let |values| be a new [=/list=].
3025+
3026+
1. [=list/For each=] |entry| of |entries|:
3027+
3028+
1. If |entry|'s [=list/size=] is not 2, [=throw=] a [=TypeError=].
3029+
3030+
1. [=list/Append=] |entry|[0] to |keys|.
3031+
3032+
Note: Keys are not [=convert a value to a key|converted=] until a subsequent step.
3033+
3034+
1. [=list/Append=] |entry|[1] to |values|.
3035+
3036+
1. Return the result of running [=add or put multiple records=] with [=/this=], |values|, false, and |keys|.
3037+
3038+
</div>
29953039

29963040
<div algorithm>
29973041

2998-
To <dfn>add or put multiple records</dfn> with |handle|, |values|, |keys|, and |no-overwrite flag|, run these steps:
3042+
To <dfn>add or put multiple records</dfn> with |handle|, |values|, |no-overwrite flag|, and optional |keys|, run these steps:
29993043

30003044
1. [=/Assert=]: If |keys| is given, |values| [=list/size=] equals |keys| [=list/size=].
30013045

@@ -6895,6 +6939,7 @@ For the revision history of the second edition, see [that document's Revision Hi
68956939
* Added {{IDBTransactionOptions/durability}} option and {{IDBTransaction/durability}} attribute. ([Issue #50](https://github.com/w3c/IndexedDB/issues/50))
68966940
* 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))
68976941
* Added <a href="#accessibility">Accessibility considerations</a> section. ([Issue #327](https://github.com/w3c/IndexedDB/issues/327))
6942+
* Added {{IDBObjectStore/putAllValues()}} and {{IDBObjectStore/putAllEntries()}} methods. ([Issue #69](https://github.com/w3c/IndexedDB/issues/69))
68986943

68996944
<!-- ============================================================ -->
69006945
# Acknowledgements # {#acknowledgements}
@@ -6941,6 +6986,7 @@ Kang-Hao Lu,
69416986
Andrea Marchesini,
69426987
Josh Matthews,
69436988
Glenn Maynard,
6989+
Numfor Mbiziwo-tiapo,
69446990
Isiah Meadows,
69456991
Ms2ger,
69466992
Odin Omdal,

0 commit comments

Comments
 (0)