@ottocode/database 0.1.313 → 0.1.315
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/index.ts +8 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ottocode/database",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.315",
|
|
4
4
|
"description": "Database and persistence layer for ottocode",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"typecheck": "tsc --noEmit"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@ottocode/sdk": "0.1.
|
|
25
|
+
"@ottocode/sdk": "0.1.315",
|
|
26
26
|
"drizzle-orm": "0.44.7"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Database } from 'bun:sqlite';
|
|
2
2
|
import { drizzle, type BunSQLiteDatabase } from 'drizzle-orm/bun-sqlite';
|
|
3
|
-
import { loadConfig, logger } from '@ottocode/sdk';
|
|
3
|
+
import { loadConfig, logger, type OttoConfig } from '@ottocode/sdk';
|
|
4
4
|
import * as schema from './schema/index.ts';
|
|
5
5
|
import { bundledMigrations } from './runtime/migrations-bundled.ts';
|
|
6
6
|
|
|
@@ -9,9 +9,15 @@ const migratedPaths = new Set<string>();
|
|
|
9
9
|
|
|
10
10
|
export async function getDb(projectRootInput?: string) {
|
|
11
11
|
const cfg = await loadConfig(projectRootInput);
|
|
12
|
-
|
|
12
|
+
return getDbForConfig(cfg);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export async function getDbForConfig(cfg: OttoConfig) {
|
|
13
16
|
// Data dir is ensured by loadConfig() already.
|
|
17
|
+
return getDbByPath(cfg.paths.dbPath);
|
|
18
|
+
}
|
|
14
19
|
|
|
20
|
+
export async function getDbByPath(dbPath: string) {
|
|
15
21
|
const key = dbPath;
|
|
16
22
|
const cached = dbCache.get(key);
|
|
17
23
|
if (cached) return cached;
|