A lightweight, composable SQL builder for TypeScript and JavaScript that constructs SQL statements programmatically without string concatenation or ORM overhead. Current stable version 0.3.4 (semver pre-1.0). It provides a flexible `sql` tagged template literal and function, along with a `ParameterCollector` for named or indexed parameters to prevent SQL injection. Key differentiators: no dependency on ORM, intuitive function-based query construction (e.g., `INSERT_INTO`, `SELECT`, `WHERE`), support for conditional fragments via falsy values, and a small API surface focused solely on SQL generation. TypeScript types included.
npm install extra-sql-builderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows building a parameterized INSERT with conditional rows using ParameterCollector.
Use only one calling convention per statement: either `sql\`...\`` or `sql(...)`.
Explicitly cast to string or use a wrapper for values that could be falsy but intended to be included.
Call `add()` with the final value and avoid mutation afterwards.
Pin exact version or use ^0.3.4 and review changelog on updates.
Ensure your project uses ESM (e.g., `"type": "module"` in package.json) and import via `import`.
Switch to ESM imports: use `import { sql } from 'extra-sql-builder'` instead of `require()`.Use `import { sql } from 'extra-sql-builder'`.Add to import: `import { INSERT_INTO, VALUES } from 'extra-sql-builder'`.No dependency data recorded yet.