MCPcopy
hub / github.com/nowork-studio/NotFair / getDb

Function getDb

notfair-cmo/src/server/db/db.ts:12–28  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10let cached: Database.Database | null = null;
11
12export function getDb(): Database.Database {
13 if (cached) return cached;
14
15 if (!existsSync(DEFAULT_DATA_DIR)) {
16 mkdirSync(DEFAULT_DATA_DIR, { recursive: true, mode: 0o700 });
17 }
18
19 const db = new Database(DB_PATH);
20 db.pragma("journal_mode = WAL");
21 db.pragma("foreign_keys = ON");
22 db.pragma("busy_timeout = 5000");
23
24 applyMigrations(db);
25
26 cached = db;
27 return db;
28}
29
30export function getDbPath(): string {
31 return DB_PATH;

Callers 15

findSessionBySessionIdFunction · 0.90
getOrCreateSessionFunction · 0.90
getSessionFunction · 0.90
listAgentSessionsFunction · 0.90
touchSessionFunction · 0.90
appendTranscriptEventFunction · 0.90
listTranscriptEventsFunction · 0.90
resolveSessionForThreadFunction · 0.90
readTranscriptTailFunction · 0.90
updateCronPromptActionFunction · 0.90
createScheduledJobFunction · 0.90

Calls 1

applyMigrationsFunction · 0.70

Tested by 1

seedProjectAndAgentFunction · 0.68