MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / openDatabase

Function openDatabase

apps/desktop/main/database/core.ts:78–86  ·  view source on GitHub ↗
(sessionId: string, readonly = true)

Source from the content-addressed store, hash-verified

76 * @param readonly 是否只读模式(默认 true)
77 */
78export 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 * 打开数据库并执行迁移(如果需要)

Callers 2

loadMessagesFunction · 0.90
getSummaryFunction · 0.90

Calls 2

getDbPathFunction · 0.70
pragmaMethod · 0.65

Tested by

no test coverage detected