dylanblokhuis/kysely-bun-sqlite

`__privateGet(this, _db2).prepare is not a function.`

Closed this issue · 2 comments

boehs commented
failed to migrate
84 |     __privateAdd(this, _db2, void 0);
85 |     __privateSet(this, _db2, db);
86 |   }
87 |   executeQuery(compiledQuery) {
88 |     const { sql: sql2, parameters } = compiledQuery;
89 |     const stmt = __privateGet(this, _db2).prepare(sql2);
                     ^
TypeError: __privateGet(this, _db2).prepare is not a function. (In '__privateGet(this, _db2).prepare(sql2)', '__privateGet(this, _db2).prepare' is undefined)
      at executeQuery (/home/evan/home/code/frantic/server/node_modules/kysely-bun-sqlite/dist/index.mjs:89:17)
      at /home/evan/home/code/frantic/server/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:34:33
      at /home/evan/home/code/frantic/server/node_modules/kysely/dist/esm/driver/default-connection-provider.js:10:25

Are migrations supported?

boehs commented

Docs would be awesome. For anyone hitting this or anything else, correct syntax is

import { Database } from "bun:sqlite"
import { Kysely } from "kysely";
import { BunSqliteDialect } from 'kysely-bun-sqlite'

export const db = new Kysely<Db>({
    dialect: new BunSqliteDialect({
        database: new Database('db.sqlite')
    })
})

NOT

import { Kysely } from "kysely";
import { BunSqliteDialect } from 'kysely-bun-sqlite'

export const db = new Kysely<Db>({
    dialect: new BunSqliteDialect({
        database: 'db.sqlite'
    })
})

I agree there should be docs, but you should've gotten a TypeError for providing a string instead of a bun:sqlite Database type.