forked from trent_larson/crowd-funder-for-time-pwa
feat: add contacts DB & page
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
import BaseDexie from "dexie";
|
||||
import BaseDexie, { Table } from "dexie";
|
||||
import { encrypted, Encryption } from "@pvermeer/dexie-encrypted-addon";
|
||||
import { accountsSchema, AccountsTable } from "./tables/accounts";
|
||||
import { accountsSchema, Account } from "./tables/accounts";
|
||||
import { contactsSchema, Contact } from "./tables/contacts";
|
||||
|
||||
type AllTables = {
|
||||
accounts: Table<Account>;
|
||||
contacts: Table<Contact>;
|
||||
};
|
||||
|
||||
/**
|
||||
* In order to make the next line be acceptable, the program needs to have its linter suppress a rule:
|
||||
@@ -10,10 +16,9 @@ import { accountsSchema, AccountsTable } from "./tables/accounts";
|
||||
*
|
||||
* https://9to5answer.com/how-to-bypass-warning-unexpected-any-specify-a-different-type-typescript-eslint-no-explicit-any
|
||||
*/
|
||||
type DexieTables = AccountsTable;
|
||||
type DexieTables = AllTables;
|
||||
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:
|
||||
@@ -27,6 +32,7 @@ const secret =
|
||||
if (localStorage.getItem("secret") == null) {
|
||||
localStorage.setItem("secret", secret);
|
||||
}
|
||||
console.log(secret);
|
||||
console.log("DB encryption secretKey:", secret);
|
||||
encrypted(db, { secretKey: secret });
|
||||
db.version(1).stores(schema);
|
||||
db.version(1).stores(accountsSchema);
|
||||
db.version(2).stores(contactsSchema);
|
||||
|
||||
Reference in New Issue
Block a user