Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions DRIVER-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ Returning an array of cells for each row, along with a separate "columns" array,

However, many current SQLite bindings do not expose the raw array calls. Even if they do, this path may be slower than using objects from the start. Since using the results as an array is quite rare in practice, this is left as an optional configuration, rather than a requirement for the all queries.

### Separate bind/step/reset

This allows a lot of flexibility, for example partial rebinding of parameters instead of specifying all parameters each time a prepared statement is used. However, those type of use cases are rare, and this is not important in the overall architecture. These could all be combined into a single "query with parameters" call, but would need to take into account optional streaming of results.

### bigint

SQLite supports up to 8-byte signed integers (up to 2^64-1), while JavaScript's number is limited to 2^53-1. General approaches include:
Expand Down
18 changes: 7 additions & 11 deletions packages/api/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SqliteArguments, SqliteRowObject } from '@sqlite-js/driver';
import { SqliteArguments, SqliteObjectRow } from '@sqlite-js/driver';

export type SqliteDatabase = SqliteConnectionPool & SqliteConnection;

Expand Down Expand Up @@ -61,19 +61,15 @@ export interface ReservedSqliteConnection extends SqliteConnection {
}

export interface QueryInterface {
prepare<T extends SqliteRowObject>(
query: string,
args?: SqliteArguments,
options?: QueryOptions
): PreparedQuery<T>;
prepare<T extends SqliteObjectRow>(query: string): PreparedQuery<T>;

run(
query: string,
args?: SqliteArguments,
options?: ReserveConnectionOptions
): Promise<RunResult>;

stream<T extends SqliteRowObject>(
stream<T extends SqliteObjectRow>(
query: string,
args: SqliteArguments,
options?: StreamOptions & ReserveConnectionOptions
Expand All @@ -84,7 +80,7 @@ export interface QueryInterface {
*
* When called on a connection pool, uses readonly: true by default.
*/
select<T extends SqliteRowObject>(
select<T extends SqliteObjectRow>(
query: string,
args?: SqliteArguments,
options?: QueryOptions & ReserveConnectionOptions
Expand All @@ -99,7 +95,7 @@ export interface QueryInterface {
* @param args
* @param options
*/
get<T extends SqliteRowObject>(
get<T extends SqliteObjectRow>(
query: string,
args?: SqliteArguments,
options?: QueryOptions & ReserveConnectionOptions
Expand All @@ -114,7 +110,7 @@ export interface QueryInterface {
* @param args
* @param options
*/
getOptional<T extends SqliteRowObject>(
getOptional<T extends SqliteObjectRow>(
query: string,
args?: SqliteArguments,
options?: QueryOptions & ReserveConnectionOptions
Expand Down Expand Up @@ -236,7 +232,7 @@ export interface RunResult {
lastInsertRowId: bigint;
}

export interface PreparedQuery<T extends SqliteRowObject> {
export interface PreparedQuery<T extends SqliteObjectRow> {
parse(): Promise<{ columns: string[] }>;

/**
Expand Down
Loading