query executes a T-SQL statement and returns the result rows as keyed records.
1
2
3
4
const rows = await client.query<{ id: number; status: string }>({
sql: "SELECT id, status FROM dbo.orders",
})
On-Behalf-Of #
Pass a bearerToken per query to run it as another identity (OBO flow). The client then uses a short-lived connection for that query instead of the shared pool:
1
2
await client.query({ sql: "SELECT 1", bearerToken: userAccessToken })
Cancellation #
Pass an AbortSignal to cancel an in-flight query:
1
2
3
4
const controller = new AbortController()
const promise = client.query({ sql: longRunningSql, signal: controller.signal })
controller.abort()
An aborted query throws a FabricCancellationError. A server-rejected statement throws a FabricQueryError. Connection and other client failures throw a FabricClientError.