(sessionId: string, readonly = true)
| 76 | * @param readonly 是否只读模式(默认 true) |
| 77 | */ |
| 78 | export function openDatabase(sessionId: string, readonly = true): Database.Database | null { |
| 79 | const dbPath = getDbPath(sessionId) |
| 80 | if (!fs.existsSync(dbPath)) { |
| 81 | return null |
| 82 | } |
| 83 | const db = new Database(dbPath, { readonly }) |
| 84 | db.pragma('journal_mode = WAL') |
| 85 | return db |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * 打开数据库并执行迁移(如果需要) |
no test coverage detected