kysely-dialect-tauri
v0.7.0
Published
Kysely Tauri dialect, using @tauri-apps/plugin-sql
Downloads
288
Maintainers
Readme
kysely-dialect-tauri
kysely dialect for Tauri
, using official sql plugin
Currently only supports SQLite
Install
pnpm add kysely kysely-dialect-tauri @tauri-apps/plugin-sql
Usage
import { appDataDir } from '@tauri-apps/api/path'
import Database from '@tauri-apps/plugin-sql'
import { Kysely } from 'kysely'
const kysely = new Kysely<DB>({
dialect: new TauriSqliteDialect({
database: prefix => Database.load(`${prefix}${await appDataDir()}test.db`)
}),
})
Config
export interface TauriSqliteDialectConfig {
database: Promisable<TauriSqlDB> | ((prefix: 'sqlite:') => Promisable<TauriSqlDB>)
/**
* Called once when the first query is executed.
*
* This is a Kysely specific feature and does not come from the `better-sqlite3` module.
*/
onCreateConnection?: (connection: DatabaseConnection) => Promisable<void>
}