aboutsummaryrefslogtreecommitdiff
path: root/src/query.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-12 21:54:14 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-12 21:54:14 +0100
commitca2a46a8575d66d529accb1ce3aaf97be8f37e2f (patch)
treec05c3452c2dfe81713cf36ce06d205faa6bfb0fa /src/query.ts
parent659435570440c5a5eacde3a2e6ef5b3f3430a45f (diff)
downloadwallet-core-ca2a46a8575d66d529accb1ce3aaf97be8f37e2f.tar.xz
precompute speculative signature for payment
Diffstat (limited to 'src/query.ts')
-rw-r--r--src/query.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/query.ts b/src/query.ts
index 9889ed13e..b199e0e9c 100644
--- a/src/query.ts
+++ b/src/query.ts
@@ -807,6 +807,38 @@ export class QueryRoot {
}
/**
+ * Get get objects from a store by their keys.
+ * If no object for a key exists, the resulting position in the array
+ * contains 'undefined'.
+ */
+ getMany<T>(store: Store<T>, keys: any[]): Promise<T[]> {
+ this.checkFinished();
+
+ const { resolve, promise } = openPromise();
+ const results: T[] = [];
+
+ const doGetMany = (tx: IDBTransaction) => {
+ for (const key of keys) {
+ if (key === void 0) {
+ throw Error("key must not be undefined");
+ }
+ const req = tx.objectStore(store.name).get(key);
+ req.onsuccess = () => {
+ results.push(req.result);
+ if (results.length == keys.length) {
+ resolve(results);
+ }
+ };
+ }
+ };
+
+ this.addWork(doGetMany, store.name, false);
+ return Promise.resolve()
+ .then(() => this.finish())
+ .then(() => promise);
+ }
+
+ /**
* Get one object from a store by its key.
*/
getIndexed<I extends IDBValidKey, T>(index: Index<I, T>,