Skip to content

Commit 842db77

Browse files
committed
Document APIs.
1 parent 8c1ea50 commit 842db77

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

DRIVER-API.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ Returning an array of cells for each row, along with a separate "columns" array,
110110

111111
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.
112112

113-
### Separate bind/step/reset
114-
115-
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.
116-
117113
### bigint
118114

119115
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:

packages/driver/src/driver-api.ts

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ export interface PrepareOptions {
1212
autoFinalize?: boolean;
1313
}
1414

15-
export interface ResetOptions {
16-
clearBindings?: boolean;
17-
}
18-
1915
export interface SqliteDriverConnection {
2016
/**
2117
* Prepare a statement.
@@ -49,19 +45,43 @@ export interface StreamQueryOptions extends QueryOptions {
4945
}
5046

5147
export interface SqliteDriverStatement {
48+
/**
49+
* Run a query, and return results as an array of row objects.
50+
*
51+
* If the query does not return results, an empty array is returned.
52+
*/
5253
all(
5354
parameters?: SqliteParameterBinding,
5455
options?: QueryOptions
5556
): Promise<SqliteObjectRow[]>;
57+
58+
/**
59+
* Run a query, and return results as an array of row arrays.
60+
*
61+
* If the query does not return results, an empty array is returned.
62+
*/
5663
allArray(
5764
parameters?: SqliteParameterBinding,
5865
options?: QueryOptions
5966
): Promise<SqliteArrayRow[]>;
6067

68+
/**
69+
* Run a query, and return as an iterator of array of row object chunks.
70+
*
71+
* It is an error to call any other query methods on the same statement
72+
* before the iterator has returned.
73+
*/
6174
stream(
6275
parameters?: SqliteParameterBinding,
6376
options?: StreamQueryOptions
6477
): AsyncIterableIterator<SqliteObjectRow[]>;
78+
79+
/**
80+
* Run a query, and return as an iterator of array of row array chunks.
81+
*
82+
* It is an error to call any other query methods on the same statement
83+
* before the iterator has returned.
84+
*/
6585
streamArray(
6686
parameters?: SqliteParameterBinding,
6787
options?: StreamQueryOptions
@@ -75,6 +95,9 @@ export interface SqliteDriverStatement {
7595
options?: QueryOptions
7696
): Promise<SqliteChanges>;
7797

98+
/**
99+
* Get the column names of the data returned by the query.
100+
*/
78101
getColumns(): Promise<string[]>;
79102

80103
finalize(): void;
@@ -86,7 +109,6 @@ export interface SqliteDriverConnectionPool {
86109
* Reserve a connection for exclusive use.
87110
*
88111
* If there is no available connection, this will wait until one is available.
89-
* @param options
90112
*/
91113
reserveConnection(
92114
options?: ReserveConnectionOptions

packages/driver/src/worker_threads/worker-driver.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import * as worker_threads from 'worker_threads';
22
import {
33
PrepareOptions,
4-
ResetOptions,
5-
SqliteDriverConnection,
6-
SqliteDriverStatement,
7-
SqliteParameterBinding,
8-
SqliteChanges,
9-
UpdateListener,
104
QueryOptions,
115
SqliteArrayRow,
6+
SqliteChanges,
7+
SqliteDriverConnection,
8+
SqliteDriverStatement,
129
SqliteObjectRow,
13-
StreamQueryOptions
10+
SqliteParameterBinding,
11+
StreamQueryOptions,
12+
UpdateListener
1413
} from '../driver-api.js';
1514

1615
import { Deferred } from '../deferred.js';

0 commit comments

Comments
 (0)