Skip to content

Commit 3dc3a56

Browse files
committed
Document batchSize as promise API only
The synchronous API reads rows one at a time and its option parsing only recognizes queryTimeout, so `statement.all(undefined, { batchSize: 250 })` binds the options object and throws, and defaultBatchSize is ignored.
1 parent 21cc2a1 commit 3dc3a56

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎docs/api.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ You can use the `options` parameter to specify various options. Options supporte
2323
- `authToken`: authentication token for the provider URL (optional).
2424
- `timeout`: number of milliseconds to wait on locked database before returning `SQLITE_BUSY` error
2525
- `defaultQueryTimeout`: default maximum number of milliseconds a query is allowed to run before being interrupted with `SQLITE_INTERRUPT` error
26-
- `defaultBatchSize`: default number of rows that the promise API reads per native iterator call. It must be an integer from 1 through 10,000 and defaults to 1.
26+
- `defaultBatchSize`: default number of rows that the promise API (`libsql/promise`) reads per native iterator call. It must be an integer from 1 through 10,000 and defaults to 1. The synchronous API ignores it.
2727

28-
Use `batchSize` in `queryOptions` to override `defaultBatchSize` for one `all()` or `iterate()` call. When the query has no bind parameters, pass `undefined` before the options: `statement.all(undefined, { batchSize: 250 })`.
28+
With the promise API, use `batchSize` in `queryOptions` to override `defaultBatchSize` for one `all()` or `iterate()` call. When the query has no bind parameters, pass `undefined` before the options: `await statement.all(undefined, { batchSize: 250 })`. The synchronous API does not support `batchSize`.
2929

3030
The function returns a `Database` object.
3131

@@ -336,7 +336,7 @@ Executes the SQL statement and returns an array of the resulting rows.
336336
| Param | Type | Description |
337337
| -------------- | ----------------------------- | ------------------------------------------------ |
338338
| bindParameters | <code>array of objects</code> | The bind parameters for executing the statement. |
339-
| queryOptions | <code>object</code> | Optional per-query overrides (for example, `{ queryTimeout: 100, batchSize: 250 }`). |
339+
| queryOptions | <code>object</code> | Optional per-query overrides (for example, `{ queryTimeout: 100 }`). The promise API also accepts `batchSize`. |
340340

341341
### iterate([...bindParameters][, queryOptions]) ⇒ iterator
342342

@@ -345,7 +345,7 @@ Executes the SQL statement and returns an iterator to the resulting rows.
345345
| Param | Type | Description |
346346
| -------------- | ----------------------------- | ------------------------------------------------ |
347347
| bindParameters | <code>array of objects</code> | The bind parameters for executing the statement. |
348-
| queryOptions | <code>object</code> | Optional per-query overrides (for example, `{ queryTimeout: 100, batchSize: 250 }`). |
348+
| queryOptions | <code>object</code> | Optional per-query overrides (for example, `{ queryTimeout: 100 }`). The promise API also accepts `batchSize`. |
349349

350350
### pluck([toggleState]) ⇒ this
351351

0 commit comments

Comments
 (0)