MCPcopy
hub / github.com/stephengpope/thepopebot / getDb

Function getDb

lib/db/index.js:18–30  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16 * @returns {import('drizzle-orm/better-sqlite3').BetterSQLite3Database}
17 */
18export function getDb() {
19 if (!_db) {
20 // Ensure database directory exists
21 const dbDir = path.dirname(thepopebotDb);
22 if (!fs.existsSync(dbDir)) {
23 fs.mkdirSync(dbDir, { recursive: true });
24 }
25 const sqlite = new Database(thepopebotDb);
26 sqlite.pragma('journal_mode = WAL');
27 _db = drizzle(sqlite, { schema });
28 }
29 return _db;
30}
31
32/**
33 * Initialize the database — apply pending migrations.

Callers 15

cleanExpiredAgentJobKeysFunction · 0.90
createApiKeyRecordFunction · 0.90
listApiKeysFunction · 0.90
deleteApiKeyByIdFunction · 0.90
deleteApiKeyFunction · 0.90
verifyApiKeyFunction · 0.90
createAgentJobApiKeyFunction · 0.90
backfillLastUsedAtFunction · 0.90
createChatFunction · 0.90
getChatsByUserFunction · 0.90
getChatByIdFunction · 0.90
getChatByWorkspaceIdFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected