Skip to content
  • Auto
  • Light
  • Dark
Get Started
View as Markdown
Copy Markdown

Open in Claude
Open in ChatGPT

Batch

client.sqlite.batch(SqliteBatchParams { statements, mode } body, RequestOptionsoptions?): SqliteBatchResponse { columns, columnTypes, rows, 2 more }
post/v1/sqlite/batch

Execute a batch of SQLite statements and return results for all of them

ParametersExpand Collapse
body: SqliteBatchParams { statements, mode }
statements: Array<string | ParameterizedQuery { args, sql } >
Accepts one of the following:
string
ParameterizedQuery { args, sql }

A parameterized SQL query. See https://docs.turso.tech/sdk/ts/reference#batch-transactions for reference

args: Array<unknown> | Record<string, unknown>

List of arguments to be used in the given statement

Accepts one of the following:
Array<unknown>
Record<string, unknown>
sql: string

SQL statement, with ? placeholders for arguments

mode?: "write" | "read" | "deferred"
Accepts one of the following:
"write"
"read"
"deferred"
ReturnsExpand Collapse
SqliteBatchResponse = Array<ResultSet { columns, columnTypes, rows, 2 more } >

Array of results from the statements executed

columns: Array<string>

Names of columns.

Names of columns can be defined using the AS keyword in SQL:

SELECT author AS author, COUNT(*) AS count FROM books GROUP BY author
columnTypes: Array<string>

Types of columns.

The types are currently shown for types declared in a SQL table. For column types of function calls, for example, an empty string is returned.

rows: Array<Array<unknown>>

Rows produced by the statement.

rowsAffected: number

Number of rows that were affected by an UPDATE, INSERT or DELETE operation.

This value is not specified for other SQL statements.

lastInsertRowid?: string | number | null

ROWID of the last inserted row.

This value is not specified if the SQL statement was not an INSERT or if the table was not a ROWID table.

Accepts one of the following:
string
number
import ValTown from "npm:@valtown/sdk";

const client = new ValTown({
  bearerToken: 'My Bearer Token',
});

const resultSets = await client.sqlite.batch({ statements: ['SELECT 1;'], mode: 'read' });

console.log(resultSets);
[
  {
    "columns": [
      "string"
    ],
    "columnTypes": [
      "string"
    ],
    "rows": [
      [
        {}
      ]
    ],
    "rowsAffected": 0,
    "lastInsertRowid": "string"
  }
]
Returns Examples
[
  {
    "columns": [
      "string"
    ],
    "columnTypes": [
      "string"
    ],
    "rows": [
      [
        {}
      ]
    ],
    "rowsAffected": 0,
    "lastInsertRowid": "string"
  }
]