initial commit
This commit is contained in:
commit
7e466e29d2
28 changed files with 17360 additions and 0 deletions
24
utils/database.ts
Normal file
24
utils/database.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { DBSchema, IDBPDatabase, openDB } from "idb";
|
||||
import { Todo, BlockedSite } from "./types";
|
||||
|
||||
interface ExtensionDatabaseScheme extends DBSchema {
|
||||
todos: {
|
||||
key: string;
|
||||
value: Todo;
|
||||
};
|
||||
blocked_sites: {
|
||||
key: string;
|
||||
value: BlockedSite;
|
||||
};
|
||||
}
|
||||
|
||||
export type ExtensionDatabase = IDBPDatabase<ExtensionDatabaseScheme>;
|
||||
|
||||
export function openExtensionDatabase(): Promise<ExtensionDatabase> {
|
||||
return openDB<ExtensionDatabaseScheme>("let-me-focus", 1, {
|
||||
upgrade(database) {
|
||||
database.createObjectStore("todos", { keyPath: "id" });
|
||||
database.createObjectStore("blocked_sites", { keyPath: "id" });
|
||||
},
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue