aboutsummaryrefslogtreecommitdiff
path: root/extension/lib/wallet/query.ts
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-01-24 02:29:13 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-01-24 02:29:13 +0100
commitb8627813be56e04c18baf38885f3a3dc0fb7496c (patch)
treee2db304d381cc343021a8af8c94b58e3554fbcc5 /extension/lib/wallet/query.ts
parent1a0a302ad9bfd49ff452bf874e04b7623e23cb5f (diff)
downloadwallet-core-b8627813be56e04c18baf38885f3a3dc0fb7496c.tar.xz
Replace handlebars with mithril, hooks for i18n.
The wallet is now a single page application.
Diffstat (limited to 'extension/lib/wallet/query.ts')
-rw-r--r--extension/lib/wallet/query.ts25
1 files changed, 7 insertions, 18 deletions
diff --git a/extension/lib/wallet/query.ts b/extension/lib/wallet/query.ts
index dda716d07..375816193 100644
--- a/extension/lib/wallet/query.ts
+++ b/extension/lib/wallet/query.ts
@@ -39,7 +39,7 @@ export interface QueryStream<T> {
indexName: string,
keyFn: (obj: any) => any): QueryStream<[T,S]>;
filter(f: (any) => boolean): QueryStream<T>;
- reduce<S>(f: (S, T) => S, acc?: S): Promise<S>;
+ reduce<S>(f: (v: T, acc: S) => S, start?: S): Promise<S>;
}
@@ -166,7 +166,7 @@ class IterQueryStream<T> extends QueryStreamBase<T> {
private storeName;
private options;
- constructor(qr, storeName, options?) {
+ constructor(qr, storeName, options) {
super(qr);
this.options = options;
this.storeName = storeName;
@@ -174,15 +174,16 @@ class IterQueryStream<T> extends QueryStreamBase<T> {
subscribe(f) {
let doIt = (tx) => {
+ const {indexName = void 0, only = void 0} = this.options;
let s;
- if (this.options && this.options.indexName) {
+ if (indexName !== void 0) {
s = tx.objectStore(this.storeName)
.index(this.options.indexName);
} else {
s = tx.objectStore(this.storeName);
}
let kr = undefined;
- if (this.options && ("only" in this.options)) {
+ if (only !== void 0) {
kr = IDBKeyRange.only(this.options.only);
}
let req = s.openCursor(kr);
@@ -218,23 +219,11 @@ class QueryRoot {
this.db = db;
}
- iter<T>(storeName): QueryStream<T> {
+ iter<T>(storeName, {only = void 0, indexName = void 0} = {}): QueryStream<T> {
this.stores.add(storeName);
- return new IterQueryStream(this, storeName);
+ return new IterQueryStream(this, storeName, {only, indexName});
}
- iterOnly<T>(storeName, key): QueryStream<T> {
- this.stores.add(storeName);
- return new IterQueryStream(this, storeName, {only: key});
- }
-
-
- iterIndex<T>(storeName, indexName, key) {
- this.stores.add(storeName);
- return new IterQueryStream(this, storeName, {indexName: indexName});
- }
-
-
/**
* Put an object into the given object store.
* Overrides if an existing object with the same key exists