Skip to main content

Introduction

SQB is a modern, all-in-one database toolkit for Node.js. Instead of picking a query builder, a connection pool, an ORM and a migration tool separately, SQB gives you all of them as one coherent, TypeScript-first toolkit — and the same code works against PostgreSQL, MySQL, MariaDB, Microsoft SQL Server, Oracle Database and SQLite, because every piece is built around a shared, dialect-agnostic query model.

You write queries once, as plain JS/TS objects:

import { Select, Eq } from '@sqb/builder';

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

...and SQB turns that into the correct SQL for whichever database you connect to — LIMIT 10 for PostgreSQL/MySQL/MariaDB/SQLite, FETCH FIRST 10 ROWS ONLY for Oracle, OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY for SQL Server — without you having to think about the difference.

Why SQB

  • One codebase, many databases. Swap the database adapter and your query code keeps working — useful for libraries, multi-tenant apps, or simply not locking yourself into one vendor.
  • Layered, not monolithic. Use just the query builder if that's all you need, add the connection/ORM layer when you need pooling and repositories, bring in the migrator or the NestJS module only if your project needs them.
  • Fast and full-featured. Built for low memory overhead and efficient handling of large result sets (streaming cursors, not just loading everything into an array) without cutting corners on capability.
  • Modern TypeScript. Full type inference for query builders and entities, targeting current Node.js and JavaScript standards.

Packages

SQB is a monorepo of small, focused packages. Most projects only need @sqb/builder, @sqb/connect, and one database adapter.

Core

PackageDescription
@sqb/builderThe SQL query builder at the core of everything else. Compose Select/Insert/Update/Delete statements as JS objects and serialize them to any supported dialect's SQL text — no driver or network connection required.
@sqb/connectThe connection layer: pooling, transactions, cursors/streaming, and a full-featured ORM (Repository, @Entity/@Column/@Link decorators) built on top of @sqb/builder.
@sqb/migratorA versioned schema and data migration runner, with SQL-script, data-insert and custom-function migration tasks.
@sqb/nestjsA NestJS module that registers an @sqb/connect client as an injectable, application-scoped provider.

Database adapters

Install the one adapter matching your database — each pulls in its own SQL dialect package automatically, so there's nothing else to add.

DatabasePackageDriver
PostgreSQL@sqb/postgresPostgreJS (pure JS)
MySQL@sqb/mysqlmysql2
MariaDB@sqb/mariadbmariadb (official)
Microsoft SQL Server@sqb/mssqlmssql (pure JS, tedious-based)
Oracle Database@sqb/oracleoracledb
SQLite (native)@sqb/sqlitenode:sqlite / bun:sqlite
SQLite (WebAssembly)@sqb/sqljssql.js

See Choosing a database adapter for help picking one.

Where to go next

  • Installation — install the builder alone, or with @sqb/connect and an adapter.
  • Quick Start — build a query, run it against a real database, and try the ORM.
  • Query Builder — what @sqb/builder does and why, then a full guide to every statement, operator, and join.
  • Connecting & Pooling — connection pooling, transactions, cursors/streaming, and schemas.
  • ORM — entities, columns, associations, and repositories.
  • Database Adapters — the built-in adapter package for each supported database.
  • Migrator — versioned schema/data migrations with @sqb/migrator.
  • Guides — the NestJS integration.
  • API Reference — generated reference docs for @sqb/builder, @sqb/connect, @sqb/migrator, @sqb/nestjs and the database adapters.

Node.js Compatibility

node >= 20.0 (the native SQLite adapter, @sqb/sqlite, requires node >= 22.5 for node:sqlite).

License

SQB is available under the Apache License 2.0.