Zero Dependency
Fully self-contained and lightweight. Works in Node.js and browsers without external packages.
High-performance SQL parsing and transformation — all starting from your existing SQL.
Install the package and build your first dynamic query:
npm install rawsql-ts
import { DynamicQueryBuilder, SqlFormatter } from 'rawsql-ts';
const baseSql = 'SELECT id, name, email, created_at FROM users WHERE active = true';
const builder = new DynamicQueryBuilder();
const query = builder.buildQuery(baseSql, {
filter: { status: 'premium', created_at: { '>': '2024-01-01' } },
sort: { created_at: { desc: true }, name: { asc: true } },
paging: { page: 2, pageSize: 10 }
});
const formatter = new SqlFormatter();
const { formattedSql, params } = formatter.format(query);
console.log(formattedSql);
console.log(params);