@sqb/builder
v6.0.9
Published
Extensible multi-dialect SQL query builder written with TypeScript
Readme
About SQB
SQB is an extensible, multi-dialect SQL query builder and Database connection wrapper for NodeJS.
About @sqb/builder
@sqb/builder is the query construction and serialization core the whole SQB stack is built on.
It lets you compose Select, Insert, Update and Delete statements as plain JavaScript/
TypeScript objects — with type-checked columns, joins, conditions and parameters — and turns them
into the correct SQL text for whichever database you're targeting, without depending on any driver
or network connection itself.
Serialization is dialect-driven: each target database (Postgres, MySQL, MariaDB, Oracle, SQL
Server, SQLite, ...) is a pluggable SerializerExtension that can override how any part of a query
is rendered — identifier quoting, LIMIT/OFFSET syntax, boolean literals, RETURNING support,
and more — while everything it doesn't override falls through to sensible defaults. This is what
lets @sqb/connect and the various dialect/adapter packages share one query-building
API across every supported database.
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, params } = query.generate({ dialect: 'postgres' });Main goals
- Single code base for any sql based database
- Powerful and simplified query coding scheme
- Fast applications with low memory requirements
- Let applications work with large data tables efficiently
- Support latest JavaScript language standards
- Lightweight and extensible framework.
You can report bugs and discuss features on the GitHub issues page
Thanks to all of the great contributions to the project.
You may want to check detailed DOCUMENTATION
Installation
$ npm install @sqb/builder --saveNode Compatibility
- node >= 20.x
License
SQB is available under MIT license.
