A lightweight, driver-agnostic SQL WHERE clause builder that uses plain JavaScript data structures and the builder pattern. Version 0.0.18 ships TypeScript types and is released on npm. Unlike many SQL builders, this library does not depend on any specific database driver or ORM, outputting raw SQL fragments with `?` placeholders. It is designed to simplify constructing parameterized WHERE clauses without string concatenation, with a focus on maintainability and minimal external dependencies. The library currently supports basic comparison operators (eq, neq, gt, gte, lt, lte) and logical grouping, but does not support indexed placeholders, joins, or subqueries. Its release cadence is infrequent, with the last update in 2024.
npm install sql-js-builderNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to build a WHERE clause with multiple conditions, destructure the SQL and values, and adapt for databases with different placeholder styles.
Write a helper function to replace `?` with indexed placeholders based on the order of values.
Avoid dynamic column names; if necessary, sanitize or quote them manually using backticks or double quotes.
Use raw SQL fragments for complex conditions or consider an alternative library with broader operator support.
Construct your own WHERE fragments manually for advanced logic, or use a more comprehensive SQL builder.
Monitor the repository for updates or consider migrating to a maintained alternative.
Change 'import where from "sql-js-builder"' to 'import { where } from "sql-js-builder"'.Quote column names manually: .and('"user status"', 'eq', 'active')Use raw SQL: `{ sql: \`"col" IN (${values.map(() => '?').join(',')})\`, values: [...] }`No dependency data recorded yet.