function queryOnePrimary
queryOnePrimary<T>(
sql: string,
args: InValue[],
): Promise<T | null>

Query an optional row on the primary (read-your-writes). Use this to read a row back immediately after committing its own write: a plain queryOne runs in "read" mode, which Turso can route to a replica lagging the just-committed write and so miss the row (returning null); routing through queryBatchPrimary ("write" mode) always hits the primary. Mirrors the same guard on syncListingPrices. args is required — every read-back keys on the written row's id.

Type Parameters

Parameters

sql: string
args: InValue[]

Return Type

Promise<T | null>

Usage

import { queryOnePrimary } from "docs/database.ts";