diff options
Diffstat (limited to 'packages/taler-wallet-core/src/query.ts')
-rw-r--r-- | packages/taler-wallet-core/src/query.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/packages/taler-wallet-core/src/query.ts b/packages/taler-wallet-core/src/query.ts index 4c169946c..994a6a96d 100644 --- a/packages/taler-wallet-core/src/query.ts +++ b/packages/taler-wallet-core/src/query.ts @@ -742,12 +742,34 @@ function makeWriteContext( return ctx; } +export interface DbAccess<StoreMap> { + idbHandle(): IDBDatabase; + runAllStoresReadWriteTx<T>( + txf: ( + tx: DbReadWriteTransaction<StoreMap, Array<StoreNames<StoreMap>>>, + ) => Promise<T>, + ): Promise<T>; + runAllStoresReadOnlyTx<T>( + txf: ( + tx: DbReadOnlyTransaction<StoreMap, Array<StoreNames<StoreMap>>>, + ) => Promise<T>, + ): Promise<T>; + runReadWriteTx<T, StoreNameArray extends Array<StoreNames<StoreMap>>>( + storeNames: StoreNameArray, + txf: (tx: DbReadWriteTransaction<StoreMap, StoreNameArray>) => Promise<T>, + ): Promise<T>; + runReadOnlyTx<T, StoreNameArray extends Array<StoreNames<StoreMap>>>( + storeNames: StoreNameArray, + txf: (tx: DbReadOnlyTransaction<StoreMap, StoreNameArray>) => Promise<T>, + ): Promise<T>; +} + /** * Type-safe access to a database with a particular store map. * * A store map is the metadata that describes the store. */ -export class DbAccess<StoreMap> { +export class DbAccessImpl<StoreMap> implements DbAccess<StoreMap> { constructor( private db: IDBDatabase, private stores: StoreMap, |