/
oriono
/
lex
Обзор
Документация
Войти
/
oriono
/
lex
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
client/src/data/db.ts
46 строк
1 KB
abo
feat: load example sentences into note field via Yandex Dictionary corpus API
02 авг 2026, 12:09
02 авг 2026, 12:09
b2de4c7
Код
Авторство
О чём код?
import Dexie, { type Table } from "dexie"; import type { Word, LanguageSettings } from "@/types"; /** Settings row: single-row table keyed by "app". */ export interface SettingsRow extends LanguageSettings { id: "app"; } export class LexDatabase extends Dexie { words!: Table<Word, number>; settings!: Table<SettingsRow, string>; constructor() { super("lex-db"); this.version(1).stores({ words: "++id, &word, next_review", settings: "id", }); this.version(2).stores({ words: "++id, &word, next_review", settings: "id", }); this.version(3).stores({ words: "++id, &word, next_review", settings: "id", }); this.version(4).stores({ words: "++id, &word, next_review", settings: "id", }); this.version(5).stores({ words: "++id, &word, next_review", settings: "id", }); } } export const db = new LexDatabase(); /** Delete all words and settings, then restore default settings. */ export async function resetAllData(): Promise<void> { await db.words.clear(); await db.settings.clear(); const { DEFAULT_LANGUAGE_SETTINGS } = await import("@/types"); await db.settings.put({ id: "app", ...DEFAULT_LANGUAGE_SETTINGS }); }