-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathexecute.ts
More file actions
29 lines (27 loc) · 872 Bytes
/
execute.ts
File metadata and controls
29 lines (27 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { HybridNitroSQLite } from '../nitro'
import type { QueryResult, QueryResultRow, SQLiteQueryParams } from '../types'
import NitroSQLiteError from '../NitroSQLiteError'
export function execute<Row extends QueryResultRow = never>(
dbName: string,
query: string,
params?: SQLiteQueryParams,
): QueryResult<Row> {
try {
const result = HybridNitroSQLite.execute(dbName, query, params)
return result as QueryResult<Row>
} catch (error) {
throw NitroSQLiteError.fromError(error)
}
}
export async function executeAsync<Row extends QueryResultRow = never>(
dbName: string,
query: string,
params?: SQLiteQueryParams,
): Promise<QueryResult<Row>> {
try {
const result = await HybridNitroSQLite.executeAsync(dbName, query, params)
return result as QueryResult<Row>
} catch (error) {
throw NitroSQLiteError.fromError(error)
}
}