add expo sqlite3. work on settings.

This commit is contained in:
Jordan
2025-01-26 09:38:17 -08:00
parent b2ec934856
commit 0876db2dea
8 changed files with 4709 additions and 6474 deletions

View File

@ -1,7 +1,7 @@
import { Translator } from "../i18n/api";
export type Speaker = {
id: string,
id: "host" | "guest",
language : string,
}

33
app/lib/db.ts Normal file
View File

@ -0,0 +1,33 @@
import * as SQLite from "react-native-sqlite-storage"
SQLite.enablePromise(true);
export const MIGRATE_UP = {
1: [
`CREATE TABLE IF NOT EXIST settings (
host_language TEXT,
libretranslate_base_url TEXT,
ui_direction INTEGER
)`,
]
}
export const MIGRATE_DOWN = {
1: [
`DROP TABLE IF EXISTS settings`
]
}
export async function getDb(migrationDirection : "up" | "down" = "up") {
const db = await SQLite.openDatabase({
name: "translation_terrace",
});
for (let [migration, statements] of Object.entries(MIGRATE_UP)) {
for (let statement of statements) {
await db.transaction(async (tx) => {
await tx.executeSql(statement)
});
}
}
}