wallet-core/src/db.ts

27 lines
675 B
TypeScript
Raw Normal View History

import { Stores, WALLET_DB_VERSION } from "./types/dbTypes";
2019-12-12 22:39:45 +01:00
import { openDatabase, Database } from "./util/query";
2019-07-31 01:33:56 +02:00
2019-12-12 22:39:45 +01:00
const TALER_DB_NAME = "taler";
2019-07-31 01:33:56 +02:00
/**
* Return a promise that resolves
* to the taler wallet db.
*/
2019-12-12 22:39:45 +01:00
export function openTalerDatabase(
2019-07-31 01:33:56 +02:00
idbFactory: IDBFactory,
onVersionChange: () => void,
onUpgradeUnsupported: (oldVersion: number, newVersion: number) => void,
): Promise<IDBDatabase> {
2019-12-12 22:39:45 +01:00
return openDatabase(
idbFactory,
TALER_DB_NAME,
WALLET_DB_VERSION,
Stores,
onVersionChange,
onUpgradeUnsupported,
);
2019-07-31 01:33:56 +02:00
}
2019-12-12 22:39:45 +01:00
export function deleteTalerDatabase(idbFactory: IDBFactory) {
Database.deleteDatabase(idbFactory, TALER_DB_NAME);
}