add expo sqlite3. work on settings.
This commit is contained in:
@ -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
33
app/lib/db.ts
Normal 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)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user