11import { HybridNitroSQLite } from '../nitro'
2- import type { NitroSQLiteQueryResult } from '../specs/NitroSQLiteQueryResult.nitro'
32import type { QueryResult , QueryResultRow , SQLiteQueryParams } from '../types'
43import NitroSQLiteError from '../NitroSQLiteError'
54
@@ -10,7 +9,7 @@ export function execute<Row extends QueryResultRow = never>(
109) : QueryResult < Row > {
1110 try {
1211 const result = HybridNitroSQLite . execute ( dbName , query , params )
13- return buildJsQueryResult < Row > ( result )
12+ return result as QueryResult < Row >
1413 } catch ( error ) {
1514 throw NitroSQLiteError . fromError ( error )
1615 }
@@ -23,25 +22,8 @@ export async function executeAsync<Row extends QueryResultRow = never>(
2322) : Promise < QueryResult < Row > > {
2423 try {
2524 const result = await HybridNitroSQLite . executeAsync ( dbName , query , params )
26- return buildJsQueryResult < Row > ( result )
25+ return result as QueryResult < Row >
2726 } catch ( error ) {
2827 throw NitroSQLiteError . fromError ( error )
2928 }
3029}
31-
32- function buildJsQueryResult < Row extends QueryResultRow = never > (
33- result : NitroSQLiteQueryResult ,
34- ) : QueryResult < Row > {
35- const data = result . results as Row [ ]
36-
37- return {
38- ...result ,
39- insertId : result . insertId ,
40- rowsAffected : result . rowsAffected ,
41- rows : {
42- _array : data ,
43- length : data . length ,
44- item : ( idx : number ) => data [ idx ] ,
45- } ,
46- } as QueryResult < Row >
47- }
0 commit comments