method DB.prototype.stream
DB.prototype.stream<T extends Record<string, any> = Record<string, any>>(
sql: string,
params?: unknown[],
): Source<T, QueryFailed>

Stream rows from a SELECT query for memory-efficient processing.

If the adapter supports cursor-based streaming (via the optional stream method), rows are yielded one at a time. Otherwise, the full result set is buffered in memory before streaming.

Examples

Example 1

const { successes, errors } = await db.stream("SELECT * FROM users").partition();

Type Parameters

T extends Record<string, any> = Record<string, any>

Parameters

sql: string
optional
params: unknown[]

Return Type

Source<T, QueryFailed>

Usage

import { DB } from ".";