Waddler <> CockroachDB
This guide assumes familiarity with:
- node-postgres basics
Waddler has native support for CockroachDB connections with the node-postgres
driver.
Step 1 - Install packages
npm
yarn
pnpm
bun
npm i waddler pg dotenv
npm i -D @types/pg
Step 2 - Initialize the driver and make a query
cockroach
cockroach with config
import 'dotenv/config';
import { waddler } from 'waddler/cockroach';
const sql = waddler(process.env.DATABASE_URL!);
const result = await sql`select 1;`;
If you need to provide your existing driver:
with existing driver
with pg-query-stream extension
import 'dotenv/config';
// Make sure to install the 'pg' package
import { waddler } from "waddler/cockroach";
import pg from 'pg';
const { Pool } = pg;
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
const sql = waddler({ client: pool });
const result = await sql`select 1;`;