1
1
import type { Dialect } from 'kysely'
2
2
import { SqliteBuilder } from 'kysely-sqlite-builder'
3
3
import type { InferDatabase } from 'kysely-sqlite-builder/schema'
4
- import { defineTable , useSchema } from 'kysely-sqlite-builder/schema'
4
+ import { column , defineTable , useSchema } from 'kysely-sqlite-builder/schema'
5
5
6
6
const tables = {
7
7
test : defineTable ( {
8
- id : { type : 'increments' } ,
9
- name : { type : 'string' } ,
10
- blobtest : { type : 'blob' } ,
11
- } , {
8
+ columns : {
9
+ id : column . increments ( ) ,
10
+ name : column . string ( ) ,
11
+ blobtest : column . blob ( ) ,
12
+ } ,
12
13
timeTrigger : { create : true , update : true } ,
13
14
} ) ,
14
15
}
@@ -23,7 +24,7 @@ export async function testDB(dialect: Dialect) {
23
24
if ( ! result . ready ) {
24
25
throw result . error
25
26
}
26
- console . log ( await db . raw ( `PRAGMA table_info('test')` ) )
27
+ console . log ( await db . execute ( `PRAGMA table_info('test')` ) )
27
28
28
29
for ( let i = 0 ; i < 10 ; i ++ ) {
29
30
await db . transaction ( async ( ) => {
@@ -32,18 +33,17 @@ export async function testDB(dialect: Dialect) {
32
33
console . log ( 'test rollback' )
33
34
throw new Error ( 'test rollback' )
34
35
}
35
- await db . execute ( d => d
36
- . insertInto ( 'test' )
36
+ await db . insertInto ( 'test' )
37
37
. values ( {
38
38
name : `test at ${ Date . now ( ) } ` ,
39
39
blobtest : Uint8Array . from ( [ 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ) ,
40
- } ) ,
41
- )
40
+ } )
41
+ . execute ( )
42
42
} )
43
43
} )
44
44
}
45
45
46
- return db . execute ( db => db . selectFrom ( 'test' ) . selectAll ( ) ) . then ( async ( data ) => {
46
+ return db . selectFrom ( 'test' ) . selectAll ( ) . execute ( ) . then ( async ( data ) => {
47
47
await db . destroy ( )
48
48
console . log ( data )
49
49
return data
0 commit comments