Skip to content

Commit

Permalink
git squash commit for getallentries.
Browse files Browse the repository at this point in the history
c9342d41e2e4e9fb55232ef48d544d6017de2cf5
Refactor to support getAllEntries

linkfy appending

IDL this and other rebasing

a4d924d4baaea4d76f4ddde9e8092f584105dbdc
add index key

544e456894468565d206102901455817d8ed2405
typo

ff1283c83570166fc7ca7283b0e6f5f33ed81917
rethink API shape

7121daf17bf1f79f1557347768166d1fd00a909e
post-rebase cleanup
  • Loading branch information
inexorabletash committed Jun 30, 2020
1 parent 59eeeb6 commit fcfe829
Showing 1 changed file with 145 additions and 76 deletions.
221 changes: 145 additions & 76 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2729,6 +2729,7 @@ interface IDBObjectStore {
optional [EnforceRange] unsigned long count);
[NewObject] IDBRequest getAllKeys(optional any query,
optional [EnforceRange] unsigned long count);
[NewObject] IDBRequest getAllEntries(optional IDBGetAllEntriesOptions options = {});
[NewObject] IDBRequest count(optional any query);

[NewObject] IDBRequest openCursor(optional any query,
Expand All @@ -2748,6 +2749,12 @@ dictionary IDBIndexParameters {
boolean unique = false;
boolean multiEntry = false;
};

dictionary IDBGetAllEntriesOptions {
any query = null;
[EnforceRange] unsigned long count;
IDBCursorDirection direction = "next";
};
</xmp>

<div class="domintro note">
Expand Down Expand Up @@ -3095,6 +3102,14 @@ The <dfn method for=IDBObjectStore>clear()</dfn> method steps are:
If successful, |request|'s {{IDBRequest/result}} will
be an [=Array=] of the [=/keys=].

: |request| = |store| . {{IDBObjectStore/getAllEntries()|getAllEntries}}(|options|)
::
Retrieves multiple [=/keys=] and [=/values=] of [=object-store/records=].

The |query| option specifies a [=/key=] or [=key range=] to match. The |count| option limits the number or records matched. Set the |direction| option to {{"next"}} to retrieve the first |count| records, or {{"prev"}} to return the last |count| records.

If successful, |request|'s {{IDBRequest/result}} will be an [=Array=], with each member being an [=Array=] with a [=/key=] [=/value=] pair.

: |request| = |store| .
{{IDBObjectStore/count()|count}}(|query|)
::
Expand Down Expand Up @@ -3191,7 +3206,7 @@ The <dfn method for=IDBObjectStore>getAll(|query|, |count|)</dfn> method steps a
[=convert a value to a key range=] with |query|.
Rethrow any exceptions.

1. Let |operation| be an algorithm to run [=retrieve multiple values from an object store=] with the [=/current Realm=], |store|, |range|, and |count| if given.
1. Let |operation| be an algorithm to run [=retrieve multiple items from an object store=] with the [=/current Realm=], |store|, |range|, "value", and |count| if given.


1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with [=/this=] and |operation|.
Expand All @@ -3200,7 +3215,7 @@ The <dfn method for=IDBObjectStore>getAll(|query|, |count|)</dfn> method steps a

<aside class=note>
The |query| parameter can be a [=/key=] or [=key range=] (an {{IDBKeyRange}})
identifying the [=object-store/records=] to be retrieved. If null or not given,
identifying the [=object-store/record=] values to be retrieved. If null or not given,
an [=unbounded key range=] is used. If |count| is specified and
there are more than |count| records in range, only the first |count|
will be retrieved.
Expand All @@ -3225,21 +3240,52 @@ The <dfn method for=IDBObjectStore>getAllKeys(|query|, |count|)</dfn> method ste
[=convert a value to a key range=] with |query|.
Rethrow any exceptions.

1. Let |operation| be an algorithm to run [=retrieve multiple keys from an object store=] with |store|, |range|, and |count| if given.
1. Let |operation| be an algorithm to run [=retrieve multiple items from an object store=] with the [=/current Realm=], |store|, |range|, "key", and |count| if given.

1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with [=/this=] and |operation|.

</div>

<aside class=note>
The |query| parameter can be a [=/key=] or [=key range=] (an {{IDBKeyRange}})
identifying the [=object-store/records=] keys to be retrieved. If null or not
identifying the [=object-store/record=] keys to be retrieved. If null or not
given, an [=unbounded key range=] is used. If |count| is specified
and there are more than |count| keys in range, only the first |count|
will be retrieved.
</aside>


<div algorithm>

The <dfn method for=IDBObjectStore>getAllEntries(|query|, |count|)</dfn> method steps are:

1. Let |transaction| be [=/this=]'s [=object-store-handle/transaction=].

1. Let |store| be [=/this=]'s [=object-store-handle/object store=].

1. If |store| has been deleted, then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.

1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.

1. Let |range| be the result of running the steps to [=convert a value to a key range=] with |query|. Rethrow any exceptions.

1. Let |operation| be an algorithm to run [=retrieve multiple items from an object store=] with the [=/current Realm=], |store|, |range|, "key+value", and |count| if given.

1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with [=/this=] and |operation|.

</div>

<aside class=note>
The |query| parameter can be a [=/key=] or [=key range=] (an {{IDBKeyRange}}) identifying the [=object-store/records=] to be retrieved. If null or not given, an [=unbounded key range=] is used. If |count| is specified and there are more than |count| keys in range, only the first |count| will be retrieved.
</aside>

<aside class=advisement>
&#x1F6A7;
The {{IDBObjectStore/getAllEntries()}} method is new in this edition.
&#x1F6A7;
</aside>


<div algorithm>

The <dfn method for=IDBObjectStore>count(|query|)</dfn> method steps are:
Expand Down Expand Up @@ -3615,6 +3661,7 @@ interface IDBIndex {
optional [EnforceRange] unsigned long count);
[NewObject] IDBRequest getAllKeys(optional any query,
optional [EnforceRange] unsigned long count);
[NewObject] IDBRequest getAllEntries(optional IDBGetAllEntriesOptions options = {});
[NewObject] IDBRequest count(optional any query);

[NewObject] IDBRequest openCursor(optional any query,
Expand Down Expand Up @@ -3763,6 +3810,13 @@ return [=/this=]'s [=index-handle/index=]'s [=unique flag=].
If successful, |request|'s {{IDBRequest/result}} will be an
[=Array=] of the [=/keys=].


: |request| = |index| . {{IDBIndex/getAllEntries()|getAllEntries}}(|query| [, |count|])
::
Retrieves the [=/keys=], [=/values=], and index [=/keys=] of [=object-store/records=] matching the given [=/key=] or [=key range=] in |query| (up to |count| if given).

If successful, |request|'s {{IDBRequest/result}} will be an [=Array=], with each member being an [=Array=] with [=/key=], [=/value=], and index [=/key=].

: |request| = |index| .
{{IDBIndex/count()|count}}(|query|)
::
Expand Down Expand Up @@ -3860,15 +3914,15 @@ The <dfn method for=IDBIndex>getAll(|query|, |count|)</dfn> method steps are:
[=convert a value to a key range=] with |query|.
Rethrow any exceptions.

1. Let |operation| be an algorithm to run [=retrieve multiple referenced values from an index=] with the [=/current Realm=], |index|, |range|, and |count| if given.
1. Let |operation| be an algorithm to run [=retrieve multiple items from an index=] with the [=/current Realm=], |index|, |range|, "value", and |count| if given.

1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with [=/this=] and |operation|.

</div>

<aside class=note>
The |query| parameter can be a [=/key=] or [=key range=] (an {{IDBKeyRange}})
identifying the [=object-store/records=] to be retrieved. If null or not given,
identifying the [=object-store/record=] values to be retrieved. If null or not given,
an [=unbounded key range=] is used. If |count| is specified and
there are more than |count| records in range, only the first |count|
will be retrieved.
Expand All @@ -3893,7 +3947,7 @@ The <dfn method for=IDBIndex>getAllKeys(|query|, |count|)</dfn> method steps are
[=convert a value to a key range=] with |query|.
Rethrow any exceptions.

1. Let |operation| be an algorithm to run [=retrieve multiple values from an index=] with |index|, |range|, and |count| if given.
1. Let |operation| be an algorithm to run [=retrieve multiple items from an index=] with the [=/current Realm=], |index|, |range|, "key", and |count| if given.

1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with [=/this=] and |operation|.

Expand All @@ -3908,6 +3962,37 @@ will be retrieved.
</aside>


<div algorithm>

The <dfn method for=IDBIndex>getAllEntries(|query|, |count|)</dfn> method steps are:

1. Let |transaction| be [=/this=]'s [=index-handle/transaction=].

1. Let |index| be [=/this=]'s [=index-handle/index=].

1. If |index| or |index|'s [=/object store=] has been deleted, then [=throw=] an "{{InvalidStateError}}" {{DOMException}}.

1. If |transaction|'s [=transaction/state=] is not [=transaction/active=], then [=throw=] a "{{TransactionInactiveError}}" {{DOMException}}.

1. Let |range| be the result of running the steps to [=convert a value to a key range=] with |query|. Rethrow any exceptions.

1. Let |operation| be an algorithm to run [=retrieve multiple items from an index=] with the [=/current Realm=], |index|, |range|, "key+value+indexKey", and |count| if given.

1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with [=/this=] and |operation|.

</div>

<aside class=note>
The |query| parameter can be a [=/key=] or [=key range=] (an {{IDBKeyRange}}) identifying the [=object-store/records=] to be retrieved. If null or not given, an [=unbounded key range=] is used. If |count| is specified and there are more than |count| keys in range, only the first |count| will be retrieved.
</aside>

<aside class=advisement>
&#x1F6A7;
The {{IDBIndex/getAllEntries()}} method is new in this edition.
&#x1F6A7;
</aside>


<div algorithm>

The <dfn method for=IDBIndex>count(|query|)</dfn> method steps are:
Expand Down Expand Up @@ -5252,7 +5337,7 @@ created [=/request=] belongs to is [=transaction/aborted=] using the steps to

1. [=/Assert=]: |transaction|'s [=transaction/state=] is [=transaction/active=].

1. If |request| was not given, let |request| be a new [=/request=] with [=request/source=] as |source|.
1. If |request| was not given, let |request| be a new [=/request=] with |source| as [=request/source=].

1. Add |request| to the end of |transaction|'s [=request list=].

Expand Down Expand Up @@ -5721,30 +5806,6 @@ To <dfn>retrieve a value from an object store</dfn> with
</div>


<div algorithm>

To <dfn>retrieve multiple values from an object
store</dfn> with |targetRealm|, |store|, |range| and optional |count|, run these steps:

1. If |count| is not given or is 0 (zero), let |count| be infinity.

1. Let |records| be a [=/list=] containing the first |count| [=object-store/records=]
in |store|'s [=object-store/list of records=] whose [=/key=] is
[=in=] |range|.

1. Let |list| be an empty [=/list=].

1. [=list/For each=] |record| of |records|:

1. Let |serialized| be |record|'s [=/value=].
1. Let |entry| be [=!=] <a abstract-op>StructuredDeserialize</a>(|serialized|, |targetRealm|).
1. Append |entry| to |list|.

1. Return |list| converted to a <code>[=/sequence=]&lt;{{any}}&gt;</code>.

</div>


<div algorithm>

To <dfn>retrieve a key from an object store</dfn>
Expand All @@ -5764,22 +5825,36 @@ with |store| and |range|, run these steps:

<div algorithm>

To <dfn>retrieve multiple keys from an object store</dfn>
with |store|, |range| and optional |count|, run these steps:
To <dfn>retrieve multiple items from an object store</dfn> with |targetRealm|, |store|, |range|, |kind| and optional |count|, run these steps:

1. If |count| is not given or is 0 (zero), let |count| be infinity.

1. Let |records| be a list containing the first |count| [=object-store/records=]
in |store|'s [=object-store/list of records=] whose [=/key=] is
[=in=] |range|.
1. Let |records| be a list containing the first |count| [=object-store/records=] in |store|'s [=object-store/list of records=] whose [=/key=] is [=in=] |range|.

1. Let |list| be an empty [=/list=].

1. [=list/For each=] |record| of |records|:
1. [=list/For each=] |record| of |records|, switching on |kind|:

<dl class=switch>
: "key"
::
1. Let |key| be the result of running [=convert a key to a value=] with |record|'s key.
1. [=list/Append=] |key| to |list|.

: "value"
::
1. Let |serialized| be |record|'s [=/value=].
1. Let |value| be [=!=] <a abstract-op>StructuredDeserialize</a>(|serialized|, |targetRealm|).
1. [=list/Append=] |value| to |list|.

1. Let |entry| be the result of running [=convert a
key to a value=] with |record|'s key.
1. Append |entry| to |list|.
: "key+value"
::
1. Let |key| be the result of running [=convert a key to a value=] with |record|'s key.
1. Let |serialized| be |record|'s [=/value=].
1. Let |value| be [=!=] <a abstract-op>StructuredDeserialize</a>(|serialized|, |targetRealm|).
1. [=list/Append=] « |key|, |value| » converted to a <code>[=/sequence=]&lt;{{any}}&gt;</code> to |list|.

</dl>

1. Return |list| converted to a <code>[=/sequence=]&lt;{{any}}&gt;</code>.

Expand Down Expand Up @@ -5807,33 +5882,6 @@ with |targetRealm|, |index| and |range|, run these steps:
</div>


<div algorithm>

To <dfn>retrieve multiple referenced values from an
index</dfn> with |targetRealm|, |index|, |range| and optional |count|, run these steps:

1. If |count| is not given or is 0 (zero), let |count| be infinity.

1. Let |records| be a list containing the first |count| [=object-store/records=]
in |index|'s [=index/list of records=] whose [=index/key=] is [=in=] |range|.

1. Let |list| be an empty [=/list=].

1. [=list/For each=] |record| of |records|:

1. Let |serialized| be |record|'s [=referenced value=].
1. Let |entry| be [=!=] <a abstract-op>StructuredDeserialize</a>(|serialized|, |targetRealm|).
1. Append |entry| to |list|.

1. Return |list| converted to a <code>[=/sequence=]&lt;{{any}}&gt;</code>.

</div>

<aside class=note>
The [=index/values=] of an [=index/record=] in an index are the keys of
[=object-store/records=] in the [=index/referenced=] object store.
</aside>

<div algorithm>

To <dfn>retrieve a value from an index</dfn> with
Expand All @@ -5852,26 +5900,46 @@ To <dfn>retrieve a value from an index</dfn> with

<div algorithm>

To <dfn>retrieve multiple values from an index</dfn> with
|index|, |range| and optional |count|, run these steps:
To <dfn>retrieve multiple items from an index</dfn> with |targetRealm|, |index|, |range|, |kind| and optional |count|, run these steps:

1. If |count| is not given or is 0 (zero), let |count| be infinity.

1. Let |records| be a list containing the first |count| [=index/records=] in
|index|'s [=index/list of records=] whose [=index/key=] is [=in=] |range|.
1. Let |records| be a list containing the first |count| [=object-store/records=] in |index|'s [=index/list of records=] whose [=index/key=] is [=in=] |range|.

1. Let |list| be an empty [=/list=].

1. [=list/For each=] |record| of |records|:
1. [=list/For each=] |record| of |records|, switching on |kind|:

1. Let |entry| be the result of running [=convert a
key to a value=] with |record|'s value.
1. Append |entry| to |list|.
<dl class=switch>
: "key"
::
1. Let |key| be the result of running [=convert a key to a value=] with |record|'s value.
1. [=list/Append=] |key| to |list|.

: "value"
::
1. Let |serialized| be |record|'s [=referenced value=].
1. Let |value| be [=!=] <a abstract-op>StructuredDeserialize</a>(|serialized|, |targetRealm|).
1. [=list/Append=] |value| to |list|.

: "key+value+indexKey"
::
1. Let |key| be the result of running [=convert a key to a value=] with |record|'s value.
1. Let |indexKey| be the result of running [=convert a key to a value=] with |record|'s key.
1. Let |serialized| be |record|'s [=referenced value=].
1. Let |value| be [=!=] <a abstract-op>StructuredDeserialize</a>(|serialized|, |targetRealm|).
1. [=list/Append=] « |key|, |value|, |indexKey| » converted to a <code>[=/sequence=]&lt;{{any}}&gt;=]</code> to |list|.

</dl>

1. Return |list| converted to a <code>[=/sequence=]&lt;{{any}}&gt;</code>.

</div>

<aside class=note>
The [=index/values=] of a [=index/record=] in an index are the keys of [=object-store/records=] in the [=index/referenced=] object store.
</aside>


<!-- ============================================================ -->
## Object store deletion operation ## {#object-store-deletion-operation}
Expand Down Expand Up @@ -6784,6 +6852,7 @@ For the revision history of the second edition, see [that document's Revision Hi
* Added {{IDBTransactionOptions/durability}} option and {{IDBTransaction/durability}} attribute. ([Issue #50](https://github.com/w3c/IndexedDB/issues/50))
* 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))
* Added <a href="#accessibility">Accessibility considerations</a> section. ([Issue #327](https://github.com/w3c/IndexedDB/issues/327))
* Added object store {{IDBObjectStore/getAllEntries()}} and index {{IDBObjectStore/getAllEntries()}} methods. ([Issue #206](https://github.com/w3c/IndexedDB/issues/206))

<!-- ============================================================ -->
# Acknowledgements # {#acknowledgements}
Expand Down

0 comments on commit fcfe829

Please sign in to comment.