File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,8 +3,18 @@ import { fileURLToPath } from "node:url";
33import * as fs from "node:fs/promises" ;
44import * 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" ;
617import { captureException , startInactiveSpan } from "@sentry/bun" ;
7- import { FileMigrationProvider , Kysely , Migrator } from "kysely" ;
818import { BunSqliteDialect } from "kysely-bun-sqlite" ;
919
1020import type { Database } from "./model.js" ;
@@ -15,13 +25,25 @@ let kysely: Kysely<Database>;
1525
1626export 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+
1839export 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 } ) ,
You can’t perform that action at this time.
0 commit comments