From ca2a46a8575d66d529accb1ce3aaf97be8f37e2f Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 12 Dec 2017 21:54:14 +0100 Subject: precompute speculative signature for payment --- src/query.ts | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'src/query.ts') diff --git a/src/query.ts b/src/query.ts index 9889ed13e..b199e0e9c 100644 --- a/src/query.ts +++ b/src/query.ts @@ -806,6 +806,38 @@ export class QueryRoot { .then(() => promise); } + /** + * 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(store: Store, keys: any[]): Promise { + 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. */ -- cgit v1.2.3