INNER CODE UNIT · JavaScript
dbPath
currycan/HaTickets · desktop/src/sql/index.js:49
export const dbPath = async () => {
return `sqlite:${await appConfigDir()}${dbName}`
}
// 初始化数据库
export const initDb = async () => {
if (db) return;
db = await Database.load(await dbPath());
};
// 初始化 日志表
export const initLogTable = async () => {
await initDb();
await db.execute(
`CREATE TABLE IF NOT EXISTS ${logTableName} (id INTEGER PRIMARY KEY AUTOINCREMENT, time TIMESTAMP NOT NULL, type TEXT, status INTEGER, title TEXT, msg TEXT);`
);
// Add index on time for query performance
await db.execute(