INNER CODE UNIT · JavaScript

initDb

currycan/HaTickets · desktop/src/sql/index.js:54

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(
        `CREATE INDEX IF NOT EXISTS idx_${logTableName}_time ON ${logTableName} (time);`
    );
};

// 初始化 设置表

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…