Skip to content
VibORM
Esc
navigateopen⌘Jpreview
On this page

Bun SQL

PostgreSQL driver using Bun's built-in SQL client

Requirements

  • Bun runtime

Configuration

import { createClient } from "viborm/bun-sql";

const client = createClient({
  databaseUrl: process.env.DATABASE_URL,
  schema,
});

Options

Option Type Description
client SQL Existing Bun SQL client
databaseUrl string PostgreSQL connection URL
options object Connection options
pgvector boolean Enable pgvector support
postgis boolean Enable PostGIS support

Options Object

Option Type Description
hostname string Database host
port number Database port
username string Database user
password string Database password
database string Database name
tls boolean | object TLS configuration
max number Maximum connections
idleTimeout number Idle connection timeout
maxLifetime number Maximum connection lifetime

Using Options

import { createClient } from "viborm/bun-sql";

const client = createClient({
  options: {
    hostname: "localhost",
    port: 5432,
    username: "postgres",
    password: "password",
    database: "mydb",
  },
  schema,
});

With pgvector

import { createClient } from "viborm/bun-sql";

const client = createClient({
  databaseUrl: process.env.DATABASE_URL,
  pgvector: true,
  schema,
});

Transactions

Bun SQL supports full transactions with savepoints for nested transactions — see Transactions.

Limitations

  • Only available in Bun runtime
  • API similar to postgres.js

Was this page helpful?