aboutsummaryrefslogtreecommitdiff
path: root/extension/lib/wallet/query.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-02-23 14:07:53 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-02-23 14:07:59 +0100
commit5591077fe9241def5fa33fc90a24681c8b7b0976 (patch)
treee4020c487d20fd7bfd7b2256ee8f2d88861dcc6a /extension/lib/wallet/query.ts
parent718f81bcd858bd50373066845727b0cf520ccd06 (diff)
repurchase detection
Diffstat (limited to 'extension/lib/wallet/query.ts')
-rw-r--r--extension/lib/wallet/query.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/extension/lib/wallet/query.ts b/extension/lib/wallet/query.ts
index b82c85189..62411dab3 100644
--- a/extension/lib/wallet/query.ts
+++ b/extension/lib/wallet/query.ts
@@ -288,6 +288,29 @@ class QueryRoot {
}
/**
+ * Get one object from a store by its key.
+ */
+ getIndexed(storeName, indexName, key): Promise<any> {
+ if (key === void 0) {
+ throw Error("key must not be undefined");
+ }
+
+ const {resolve, promise} = openPromise();
+
+ const doGetIndexed = (tx) => {
+ const req = tx.objectStore(storeName).index(indexName).get(key);
+ req.onsuccess = (r) => {
+ resolve(req.result);
+ };
+ };
+
+ this.addWork(doGetIndexed, storeName, false);
+ return Promise.resolve()
+ .then(() => this.finish())
+ .then(() => promise);
+ }
+
+ /**
* Finish the query, and start the query in the first place if necessary.
*/
finish(): Promise<void> {