snapsteps/src/lib/db.ts
johannes-hernehult 7cdeb98161 feat(guides): integrate GuideContext and persist new guides to IndexedDB
- Wrap application root with IDBProvider and GuideProvider
    - Replace mock data in App component with real guides from useGuides hook
    - Update useNewGuide hook to save compiled guides to IndexedDB and update global state
2026-06-17 11:12:25 +02:00

19 lines
439 B
TypeScript

import { openDB, type DBSchema, type IDBPDatabase } from "idb";
import type { CompiledGuideType } from "./schemas";
export interface MyDB extends DBSchema {
guides: {
key: string;
value: CompiledGuideType;
};
}
export type AppDB = IDBPDatabase<MyDB>;
export function initDB(): Promise<AppDB> {
return openDB<MyDB>("my-guides", 1, {
upgrade(db) {
db.createObjectStore("guides", { keyPath: "id" });
},
});
}