Waddler stream

This guide assumes familiarity with:

Note

Stream is not implemented in postgres.js, xata-http, pglite, neon-http, bun-sql

All other drivers have support for a stream feature

.stream() lets you stream query result rows one by one:

IMPORTANT

To enable streaming in node-postgres and other PostgreSQL drivers, you need to install pg-query-stream and the query-stream extension that provides streaming support. You can read more about extensions here

npm
yarn
pnpm
bun
npm i pg-query-stream
import { queryStream } from 'waddler/extensions/pg-query-stream';

const sql = waddler(process.env.DATABASE_URL!, { extensions: [queryStream()] })
for await
generator
const result = sql`select * from users`.stream();

for await (const row of result) {
  console.log(row);
}
{
  id: 1,
	name: "Alex",
}
{
  id: 2,
	name: "Oleksii",
}