MCPcopy Index your code
hub / github.com/Waishnav/devspace / openDatabase

Function openDatabase

src/db/client.ts:21–38  ·  view source on GitHub ↗
(stateDir: string)

Source from the content-addressed store, hash-verified

19}
20
21export function openDatabase(stateDir: string): DatabaseHandle {
22 mkdirSync(stateDir, { recursive: true, mode: 0o700 });
23 chmodSync(stateDir, 0o700);
24 const path = databasePath(stateDir);
25 const sqlite = new Database(path);
26 chmodSync(path, 0o600);
27 sqlite.pragma("journal_mode = WAL");
28 sqlite.pragma("synchronous = NORMAL");
29 sqlite.pragma("busy_timeout = 5000");
30 sqlite.pragma("foreign_keys = ON");
31 migrateDatabase(sqlite);
32
33 return {
34 sqlite,
35 db: createDrizzleDatabase(sqlite),
36 close: () => sqlite.close(),
37 };
38}
39
40function createDrizzleDatabase(sqlite: SqliteDatabase) {
41 return drizzle(sqlite, { schema });

Callers 4

constructorMethod · 0.85
constructorMethod · 0.85

Calls 4

databasePathFunction · 0.85
migrateDatabaseFunction · 0.85
createDrizzleDatabaseFunction · 0.85
closeMethod · 0.65

Tested by 2