From 2390349b94d12a12ff8e7d2dd673985b109c4f13 Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Wed, 12 Jun 2019 10:22:56 -0700 Subject: [PATCH] Refactor to support getAllEntries linkfy appending IDL this and other rebasing --- index.bs | 248 +++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 175 insertions(+), 73 deletions(-) diff --git a/index.bs b/index.bs index 8783608..0e3ea71 100644 --- a/index.bs +++ b/index.bs @@ -2754,6 +2754,8 @@ interface IDBObjectStore { optional [EnforceRange] unsigned long count); [NewObject] IDBRequest getAllKeys(optional any query, optional [EnforceRange] unsigned long count); + [NewObject] IDBRequest getAllEntries(optional any query, + optional [EnforceRange] unsigned long count); [NewObject] IDBRequest count(optional any query); [NewObject] IDBRequest openCursor(optional any query, @@ -3134,6 +3136,17 @@ must run these steps: If successful, |request|'s {{IDBRequest/result}} will be an [=Array=] of the [=/keys=]. + : |request| = |store| . + {{IDBObjectStore/getAllEntries()|getAllEntries}}(query [, + |count|]) + :: + Retrieves the [=/keys=] and [=/values=] 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 a [=/key=] + [=/value=] pair. + : |request| = |store| . {{IDBObjectStore/count()|count}}(|query|) :: @@ -3240,14 +3253,14 @@ method, when invoked, must run these steps: 1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with **this** as |source| and - [=retrieve multiple values from an object store=] + [=retrieve multiple items from an object store=] as |operation|, using the [=current Realm=] as |targetRealm|, - |store|, |range|, and |count| if given. + |store|, |range|, "value" as |kind|, and |count| if given. The |query| parameter may 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. @@ -3275,17 +3288,59 @@ method, when invoked, must run these steps: 1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with **this** as |source| and - [=retrieve multiple keys from an object store=] as - |operation|, using |store|, |range|, and |count| if given. + [=retrieve multiple items from an object store=] as + |operation|, using the [=current Realm=] as |targetRealm|, + |store|, |range|, "key" as |kind|, and |count| if given. + + + +The |query| parameter may be a [=/key=] or [=key range=] (an {{IDBKeyRange}}) +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. + + +
+ +The getAllEntries(|query|, |count|) +method, when invoked, must run these steps: + +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, [=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. Return the result (an {{IDBRequest}}) of running + [=asynchronously execute a request=] + with **this** as |source| and + [=retrieve multiple items from an object store=] as + |operation|, using the [=current Realm=] as |targetRealm|, + |store|, |range|, "key+value", and |count| if given.
The |query| parameter may 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/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. + +
@@ -3666,6 +3721,8 @@ interface IDBIndex { optional [EnforceRange] unsigned long count); [NewObject] IDBRequest getAllKeys(optional any query, optional [EnforceRange] unsigned long count); + [NewObject] IDBRequest getAllEntries(optional any query, + optional [EnforceRange] unsigned long count); [NewObject] IDBRequest count(optional any query); [NewObject] IDBRequest openCursor(optional any query, @@ -3813,6 +3870,18 @@ 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=] and [=/values=] 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 a [=/key=] + [=/value=] pair. + : |request| = |index| . {{IDBIndex/count()|count}}(|query|) :: @@ -3923,14 +3992,14 @@ when invoked, must run these steps: 1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with **this** as |source| and - [=retrieve multiple referenced values from an index=] as + [=retrieve multiple items from an index=] as |operation|, using the [=current Realm=] as |targetRealm|, - |index|, |range|, and |count| if given. + |index|, |range|, "value" as |kind|, and |count| if given.
The |query| parameter may 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. @@ -3958,18 +4027,60 @@ method, when invoked, must run these steps: 1. Return the result (an {{IDBRequest}}) of running [=asynchronously execute a request=] with **this** as |source| and - [=retrieve multiple values from an index=] as |operation|, using - |index|, |range|, and |count| if given. + [=retrieve multiple items from an index=] as |operation|, using + the [=current Realm=] as |targetRealm|, + |index|, |range|, "key" as |kind|, and |count| if given. The |query| parameter may 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. +
+ +The getAllEntries(|query|, |count|) +method, when invoked, must run these steps: + +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, [=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. Return the result (an {{IDBRequest}}) of running + [=asynchronously execute a request=] + with **this** as |source| and + [=retrieve multiple items from an index=] as |operation|, using + the [=current Realm=] as |targetRealm|, + |index|, |range|, "key+value" as |kind|, and |count| if given. + +
+ +The |query| parameter may 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. + + + +
The count(|query|) method, when @@ -5777,30 +5888,6 @@ To retrieve a value from an object store with
-
- -To retrieve multiple values from an object -store 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 [=!=] StructuredDeserialize(|serialized|, |targetRealm|). - 1. Append |entry| to |list|. - -1. Return |list| converted to a [=sequence<any>=]. - -
- -
To retrieve a key from an object store @@ -5820,8 +5907,8 @@ with |store| and |range|, run these steps:
-To retrieve multiple keys from an object store -with |store|, |range| and optional |count|, run these steps: +To retrieve multiple items from an object store +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. @@ -5831,11 +5918,29 @@ with |store|, |range| and optional |count|, run these steps: 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 key. - 1. Append |entry| to |list|. +
+ : "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 [=!=] StructuredDeserialize(|serialized|, |targetRealm|). + 1. [=list/Append=] |value| 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 [=!=] StructuredDeserialize(|serialized|, |targetRealm|). + 1. Let |pair| be a [=/list=] containing |key| and |value|. + 1. [=list/Append=] |pair| convered to a [=sequence<any>=] to |list|. + +
1. Return |list| converted to a [=sequence<any>=]. @@ -5863,30 +5968,8 @@ with |targetRealm|, |index| and |range|, run these steps:
-
- -To retrieve multiple referenced values from an -index 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 [=!=] StructuredDeserialize(|serialized|, |targetRealm|). - 1. Append |entry| to |list|. - -1. Return |list| converted to a [=sequence<any>=]. - -
- @@ -5908,21 +5991,39 @@ To retrieve a value from an index with
-To retrieve multiple values from an index with -|index|, |range| and optional |count|, run these steps: +To retrieve multiple items from an index 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|. +
+ : "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 [=!=] StructuredDeserialize(|serialized|, |targetRealm|). + 1. [=list/Append=] |value| to |list|. + + : "key+value" + :: + 1. Let |key| be the result of running [=convert a key to a value=] with |record|'s value. + 1. Let |serialized| be |record|'s [=referenced value=]. + 1. Let |value| be [=!=] StructuredDeserialize(|serialized|, |targetRealm|). + 1. Let |pair| be a [=/list=] containing |key| and |value|. + 1. [=list/Append=] |pair| convered to a [=sequence<any>=] to |list|. + +
1. Return |list| converted to a [=sequence<any>=]. @@ -6815,6 +6916,7 @@ For the revision history of the second edition, see [that document's Revision Hi * Removed handling for nonstandard `lastModifiedDate` property of {{File}} objects. ([Issue #215](https://github.com/w3c/IndexedDB/issues/215)) * Remove escaping {{IDBKeyRange/includes()}} method. ([Issue #294](https://github.com/w3c/IndexedDB/issues/294)) * Restrict array keys to [=/Array exotic objects=] (i.e. disallow proxies). ([Issue #309](https://github.com/w3c/IndexedDB/issues/309]) +* Added object store {{IDBObjectStore/getAllEntries()}} and index {{IDBObjectStore/getAllEntries()}} methods. ([Issue #206](https://github.com/w3c/IndexedDB/issues/206)) # Acknowledgements # {#acknowledgements}