We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 40487bf commit 7b5036cCopy full SHA for 7b5036c
packages/dialect-bun-worker/src/worker.ts
@@ -3,9 +3,9 @@ import type { QueryResult } from 'kysely'
3
import type { MainMsg, RunMsg, WorkerMsg } from './type'
4
5
let db: Database
6
-let cache: boolean | undefined
+let fn: 'query' | 'prepare'
7
function run({ isSelect, sql, parameters }: RunMsg): QueryResult<any> {
8
- const stmt = db[cache ? 'query' : 'prepare'](sql)
+ const stmt = db[fn](sql)
9
const rows = stmt.all(parameters as any)
10
11
if (isSelect || rows.length) {
@@ -37,7 +37,7 @@ onmessage = ({ data }: MessageEvent<MainMsg>) => {
37
break
38
case 'init':
39
db = new Database(data.url, { create: true })
40
- cache = data.cache
+ fn = data.cache ? 'prepare' : 'query'
41
42
}
43
} catch (error) {
0 commit comments