File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
using [ Tauri official sqlite plugin] ( https://github.com/tauri-apps/plugins-workspace/tree/dev/plugins/sql )
4
4
5
+ ### usage
6
+
7
+ ``` ts
8
+ const kysely = new Kysely <DB >({
9
+ dialect: new TauriSqlDialect ({
10
+ database: Database .load (` sqlite:${await appDataDir ()}test.db ` )
11
+ }),
12
+ })
13
+ ```
14
+
5
15
### type
6
16
7
17
``` ts
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ export class TaruiSqlDriver {
15
15
async init ( ) : Promise < void > {
16
16
this . db = typeof this . config . database === 'function'
17
17
? await this . config . database ( )
18
- : this . config . database
18
+ : await this . config . database
19
19
this . connection = new TauriSqlConnection ( this . db )
20
20
if ( this . config . onCreateConnection ) {
21
21
await this . config . onCreateConnection ( this . connection )
Original file line number Diff line number Diff line change @@ -5,9 +5,18 @@ import type { TauriSqlDB } from './type'
5
5
6
6
export interface TauriSqlDialectConfig {
7
7
/**
8
- * The path is relative to `tauri::api::path::BaseDirectory::App`.
8
+ * Tauri database instance.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const kysely = new Kysely<DB>({
13
+ * dialect: new TauriSqlDialect({
14
+ * database: Database.load(`sqlite:${await appDataDir()}test.db`)
15
+ * }),
16
+ * })
17
+ * ```
9
18
*/
10
- database : TauriSqlDB | ( ( ) => Promise < TauriSqlDB > )
19
+ database : TauriSqlDB | Promise < TauriSqlDB > | ( ( ) => Promise < TauriSqlDB > )
11
20
/**
12
21
* Called once when the first query is executed.
13
22
*
You can’t perform that action at this time.
0 commit comments