Skip to content

Commit b728f27

Browse files
committed
Test log
1 parent 29210c1 commit b728f27

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

src/storage/db/db.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@ import { fileURLToPath } from "node:url";
33
import * as fs from "node:fs/promises";
44
import * as path from "node:path";
55

6+
import {
7+
type KyselyPlugin,
8+
FileMigrationProvider,
9+
Kysely,
10+
Migrator,
11+
type PluginTransformResultArgs,
12+
type QueryResult,
13+
type UnknownRow,
14+
type PluginTransformQueryArgs,
15+
type RootOperationNode,
16+
} from "kysely";
617
import { captureException, startInactiveSpan } from "@sentry/bun";
7-
import { FileMigrationProvider, Kysely, Migrator } from "kysely";
818
import { BunSqliteDialect } from "kysely-bun-sqlite";
919

1020
import type { Database } from "./model.js";
@@ -15,13 +25,25 @@ let kysely: Kysely<Database>;
1525

1626
export default () => kysely;
1727

28+
const plugin = {
29+
transformQuery(args: PluginTransformQueryArgs): RootOperationNode {
30+
return args.node;
31+
},
32+
async transformResult(args: PluginTransformResultArgs): Promise<QueryResult<UnknownRow>> {
33+
const r = args.result.rows;
34+
log.info(r[0], "Row");
35+
return args.result;
36+
},
37+
} satisfies KyselyPlugin;
38+
1839
export async function connectToDb(databasePath: string) {
1940
if (kysely) {
2041
return;
2142
}
2243

2344
const nativeDb = new SqliteDatabase(databasePath);
2445
const db = new Kysely<Database>({
46+
plugins: [plugin],
2547
dialect: new BunSqliteDialect({
2648
database: nativeDb,
2749
}),

0 commit comments

Comments
 (0)