mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
support idb store/index.count
This commit is contained in:
parent
a791641b34
commit
524090e27d
@ -37,6 +37,7 @@ interface QueryTargetInterface<T> {
|
|||||||
openKeyCursor(range?: IDBQuery, direction?: IDBCursorDirection | undefined): IDBRequest<IDBCursor | null>;
|
openKeyCursor(range?: IDBQuery, direction?: IDBCursorDirection | undefined): IDBRequest<IDBCursor | null>;
|
||||||
supports(method: string): boolean;
|
supports(method: string): boolean;
|
||||||
keyPath: string | string[];
|
keyPath: string | string[];
|
||||||
|
count(keyRange?: IDBKeyRange): IDBRequest<number>;
|
||||||
get(key: IDBValidKey | IDBKeyRange): IDBRequest<T | undefined>;
|
get(key: IDBValidKey | IDBKeyRange): IDBRequest<T | undefined>;
|
||||||
getKey(key: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey | undefined>;
|
getKey(key: IDBValidKey | IDBKeyRange): IDBRequest<IDBValidKey | undefined>;
|
||||||
}
|
}
|
||||||
@ -78,6 +79,10 @@ export class QueryTarget<T> {
|
|||||||
return this._target.supports(methodName);
|
return this._target.supports(methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count(keyRange?: IDBKeyRange): Promise<number> {
|
||||||
|
return reqAsPromise(this._target.count(keyRange));
|
||||||
|
}
|
||||||
|
|
||||||
get(key: IDBValidKey | IDBKeyRange): Promise<T | undefined> {
|
get(key: IDBValidKey | IDBKeyRange): Promise<T | undefined> {
|
||||||
return reqAsPromise(this._target.get(key));
|
return reqAsPromise(this._target.get(key));
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,14 @@ export class QueryTargetWrapper<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
count(keyRange?: IDBKeyRange): IDBRequest<number> {
|
||||||
|
try {
|
||||||
|
return this._qtStore.count(keyRange);
|
||||||
|
} catch(err) {
|
||||||
|
throw new IDBRequestAttemptError("count", this._qt, err, [keyRange]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
index(name: string): IDBIndex {
|
index(name: string): IDBIndex {
|
||||||
try {
|
try {
|
||||||
return this._qtStore.index(name);
|
return this._qtStore.index(name);
|
||||||
|
Loading…
Reference in New Issue
Block a user