MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / createDatabaseWithoutIndexes

Function createDatabaseWithoutIndexes

apps/desktop/main/worker/import/utils.ts:35–51  ·  view source on GitHub ↗
(sessionId: string)

Source from the content-addressed store, hash-verified

33 * Indexes should be created via createIndexes() after import completes.
34 */
35export function createDatabaseWithoutIndexes(sessionId: string): Database.Database {
36 const dbDir = getDbDir()
37 if (!fs.existsSync(dbDir)) {
38 fs.mkdirSync(dbDir, { recursive: true })
39 }
40
41 const dbPath = getDbPath(sessionId)
42 const db = new Database(dbPath)
43
44 db.pragma('journal_mode = WAL')
45 db.pragma('synchronous = NORMAL')
46 db.pragma('cache_size = -64000') // 64MB cache for write performance
47
48 db.exec(CHAT_DB_TABLES)
49
50 return db
51}
52
53/**
54 * Create indexes after bulk import completes.

Callers 1

openDatabaseFunction · 0.90

Calls 4

getDbDirFunction · 0.90
getDbPathFunction · 0.70
pragmaMethod · 0.65
execMethod · 0.65

Tested by

no test coverage detected