Skip to main content
Meet

SQB

One Database Toolkit for all SQL Databases

A multi-dialect query builder, connection pooling, a full ORM, and migrations — one coherent, TypeScript-first toolkit that speaks PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, and SQLite the same way.

One Codebase, All Databases.

Swap the adapter, not your queries — the same Select/Insert/Update/Delete code runs unmodified against PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, and SQLite.

Layered, Not Monolithic.

Use the query builder on its own — no driver, no network connection. Add pooling and the ORM when you need them; bring in the migrator or the NestJS module only if your project does.

Modern TypeScript, Throughout.

Full type inference for query builders and entities, targeting current Node.js and JavaScript standards — the compiler catches what a stale comment would only suggest.

Start with just a query. Grow into the rest.

The builder alone needs no driver or connection. Add a client and an entity when you're ready for pooling, transactions, and a typed repository.

Just the query builder
import '@sqb/postgres-dialect';
import { Select, Eq } from '@sqb/builder';

const query = Select('id', 'given_name', 'family_name')
.from('customers')
.where(Eq('active', true))
.orderBy('id')
.limit(10);

const { sql } = query.generate({ dialect: 'postgres' });
console.log(sql);
// select id, given_name, family_name from customers
// where active = true order by id LIMIT 10
With a client and a repository
import '@sqb/postgres';
import { SqbClient } from '@sqb/connect';

const client = new SqbClient({
dialect: 'postgres',
host: 'localhost',
database: 'mydb',
});

const repo = client.getRepository(Customer);
const customers = await repo.findMany({
filter: { active: true },
sort: ['givenName'],
limit: 20,
});

Everything a database toolkit should do

A query builder that reads like SQL.

Compose Select, Insert, Update, and Delete statements as sequential JS calls, then generate() dialect-correct SQL text — no driver or network connection required.

Connection pooling built in.

Acquire connections, run transactions with savepoints, or stream large result sets through a cursor — all through one client, no separate pooling library.

A real ORM, decorators included.

@Entity, @Column, @PrimaryKey, and @Link turn plain classes into repositories with typed find/create/update/delete methods and lazy, chainable associations.

Versioned schema migrations.

A migration runner with SQL-script, data-insert, and custom-function tasks, organized into versioned steps you can target and roll forward through.

Drops straight into NestJS.

SqbModule.forRoot() and forRootAsync() register a client as an injectable, application-scoped provider — no adapter glue code to write yourself.

Six dialects, one shared query model.

Every adapter package pulls in its dialect module and self-registers on import — the query builder already knows how each database wants its SQL shaped.

Ready to query?

Install SQB and build your first query in a few lines.

Read the docs →