kysely-dialect-tauri
TypeScript icon, indicating that this package has built-in type declarations

0.6.0 • Public • Published

kysely-dialect-tauri

kysely dialect for Tauri, using official sql plugin, support MySQL, PostgreSQL and SQLite

Install

pnpm add kysely kysely-dialect-tauri @tauri-apps/plugin-sql

Usage

import { Kysely } from 'kysely'
import Database from '@tauri-apps/plugin-sql'
import { appDataDir } from '@tauri-apps/api/path'

const kysely = new Kysely<DB>({
  dialect: new TauriSqlDialect({
    type: 'sqlite',
    database: prefix => Database.load(`${prefix}${await appDataDir()}test.db`)
  }),
})

Config

export interface TauriSqlDialectConfig<T extends 'sqlite' | 'mysql' | 'postgres'> {
  database: Promisable<TauriSqlDB> | ((prefix: T extends 'sqlite' ? `${T}:` : `${T}://`) => Promisable<TauriSqlDB>)
  type: T
  onCreateConnection?: (connection: DatabaseConnection) => Promisable<void>
}

Package Sidebar

Install

npm i kysely-dialect-tauri

Weekly Downloads

23

Version

0.6.0

License

MIT

Unpacked Size

13.8 kB

Total Files

7

Last publish

Collaborators

  • subframe7536