DB being created. Still getting an exception.

This commit is contained in:
Matthew Aaron Raymer
2022-12-15 16:45:38 +08:00
parent 9232afb5af
commit 3ac8f911ac
2 changed files with 18 additions and 12 deletions

View File

@@ -17,8 +17,12 @@ export type Dexie<T extends unknown = DexieTables> = BaseDexie & T;
export const db = new BaseDexie("kickStarter") as Dexie;
const schema = Object.assign({}, accountsSchema);
/**
* Needed to enable a special webpack setting to allow *await* below:
* https://stackoverflow.com/questions/72474803/error-the-top-level-await-experiment-is-not-enabled-set-experiments-toplevelaw
*/
// if db already made, skip creation
BaseDexie.exists("kickStarter").then(function (exists) {
const exists = await BaseDexie.exists("kickStarter");
if (exists == false) {
// create password and place password in localStorage
const secret =
@@ -31,4 +35,3 @@ BaseDexie.exists("kickStarter").then(function (exists) {
encrypted(db, { secretKey: secret });
db.version(1).stores(schema);
}
});

View File

@@ -3,5 +3,8 @@ module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: {
devtool: "source-map",
experiments: {
topLevelAwait: true,
}
},
});