Closed Aeryle closed 1 year ago
maybe just a type error. the return type of close does not affect the logic https://github.com/subframe7536/kysely-sqlite-tools/blob/4fde7802e16cd9d250e0997764d42a131946910d/packages/dialect-tauri/src/driver.ts#L48-L50
I think those types are related to the error I get:
Maybe Db.load()
from the tauri-plugin-sql-api
is not the API to use? Do you have an example, docs or template I could check to see how it should be done?
import Database from "tauri-plugin-sql-api";
import { Generated, Kysely } from "kysely";
import { TauriSqlDialect } from "kysely-dialect-tauri";
import { appDataDir } from "@tauri-apps/api/path";
interface DB {
test: TestTable
}
interface TestTable {
id: Generated<number>
name: string
age: number
int8: Uint8Array
}
export async function test() {
const kysely = new Kysely<DB>({
dialect: new TauriSqlDialect({
database: async () => await Database.load(
`sqlite:${await appDataDir()}test.db`
) as any // bypass typecheck, fixed in https://github.com/subframe7536/kysely-sqlite-tools/commit/4fde7802e16cd9d250e0997764d42a131946910d
}),
})
await kysely.schema.dropTable('test').execute()
await kysely.schema.createTable('test')
.addColumn('id', 'integer', builder => builder.autoIncrement().primaryKey())
.addColumn('name', 'text')
.addColumn('age', 'integer')
.addColumn('int8', 'blob')
.execute()
await kysely.insertInto('test')
.values({
age: 18,
name: `test at ${Date.now()}`,
int8: new Uint8Array([1, 2, 3]),
})
.execute()
console.table(await kysely
.selectFrom('test')
.selectAll()
.executeTakeFirstOrThrow()
)
}
call test()
in Vue
Hello,
I have been trying the
kysely-dialect-tauri
module, but since there is no documentation, or examples in any form or shape that could help, I have been trying to understand how to use it, and here is my code:I can't seem to get the types to correspond, and unless I'm overseeing something, I don't understand why not use the type already used by the
Db.load
function?