diff options
Diffstat (limited to 'packages/taler-wallet-core/src/util')
-rw-r--r-- | packages/taler-wallet-core/src/util/query.ts | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/packages/taler-wallet-core/src/util/query.ts b/packages/taler-wallet-core/src/util/query.ts index 8274e252b..d96a03c61 100644 --- a/packages/taler-wallet-core/src/util/query.ts +++ b/packages/taler-wallet-core/src/util/query.ts @@ -23,20 +23,19 @@ /** * Imports. */ -import { openPromise } from "./promiseUtils.js"; import { - IDBRequest, - IDBTransaction, - IDBValidKey, + IDBCursor, IDBDatabase, IDBFactory, - IDBVersionChangeEvent, - IDBCursor, IDBKeyPath, IDBKeyRange, - IDBOpenDBRequest, + IDBRequest, + IDBTransaction, + IDBValidKey, + IDBVersionChangeEvent, } from "@gnu-taler/idb-bridge"; -import { Codec, Logger, j2s } from "@gnu-taler/taler-util"; +import { Codec, Logger } from "@gnu-taler/taler-util"; +import { openPromise } from "./promiseUtils.js"; const logger = new Logger("query.ts"); @@ -374,6 +373,10 @@ type GetIndexReadWriteAccess<RecordType, IndexMap> = { export interface StoreReadOnlyAccessor<RecordType, IndexMap> { get(key: IDBValidKey): Promise<RecordType | undefined>; + getAll( + query?: IDBKeyRange | IDBValidKey, + count?: number, + ): Promise<RecordType[]>; iter(query?: IDBValidKey): ResultStream<RecordType>; indexes: GetIndexReadOnlyAccess<RecordType, IndexMap>; } @@ -387,6 +390,10 @@ export interface InsertResponse { export interface StoreReadWriteAccessor<RecordType, IndexMap> { get(key: IDBValidKey): Promise<RecordType | undefined>; + getAll( + query?: IDBKeyRange | IDBValidKey, + count?: number, + ): Promise<RecordType[]>; iter(query?: IDBValidKey): ResultStream<RecordType>; put(r: RecordType, key?: IDBValidKey): Promise<InsertResponse>; add(r: RecordType, key?: IDBValidKey): Promise<InsertResponse>; @@ -717,6 +724,10 @@ function makeReadContext( const req = tx.objectStore(storeName).get(key); return requestToPromise(req); }, + getAll(query, count) { + const req = tx.objectStore(storeName).getAll(query, count); + return requestToPromise(req); + }, iter(query) { const req = tx.objectStore(storeName).openCursor(query); return new ResultStream<any>(req); @@ -770,6 +781,10 @@ function makeWriteContext( const req = tx.objectStore(storeName).get(key); return requestToPromise(req); }, + getAll(query, count) { + const req = tx.objectStore(storeName).getAll(query, count); + return requestToPromise(req); + }, iter(query) { const req = tx.objectStore(storeName).openCursor(query); return new ResultStream<any>(req); |