Drizzle <> Bun SQL
This guide assumes familiarity with:
- Database connection basics with Drizzle
- Bun - website
- Bun SQL - native bindings for working with PostgreSQL databases - read here
According to the official website, Bun is a fast all-in-one JavaScript runtime.
Drizzle ORM natively supports bun sql
module and it’s crazy fast 🚀
Step 1 - Install packages
npm
yarn
pnpm
bun
npm i drizzle-orm npm i -D drizzle-kit
Step 2 - Initialize the driver and make a query
import 'dotenv/config'; import { drizzle } from 'drizzle-orm/bun-sql'; const db = drizzle(process.env.DATABASE_URL); const result = await db.select().from(...);
If you need to provide your existing driver:
import 'dotenv/config'; import { drizzle } from 'drizzle-orm/bun-sql'; import { SQL } from 'bun'; const client = new SQL(process.env.DATABASE_URL!); const db = drizzle({ client });