sql-select-ts is a modern, database-agnostic SELECT query builder for JavaScript and TypeScript, currently stable at version 2.0.18. It distinguishes itself through its composable API and strong static type checking, making it an excellent choice for projects prioritizing type safety and maintainable SQL generation. The package exhibits a frequent release cadence, with numerous minor updates and bug fixes being published regularly, indicating active development and responsiveness to community feedback. Its core value proposition lies in enabling developers to construct complex SELECT queries programmatically without sacrificing type safety or database portability, moving beyond raw string concatenation or less type-safe alternatives. It focuses specifically on SELECT statements, offering a streamlined API for this common database operation, and is suitable for both Node.js and browser environments.
npm install sql-select-tsVerified import paths — ran on the pinned version, not inferred.
Demonstrates building a multi-table SELECT query with aliased columns, aggregates, joins, complex WHERE clauses, grouping, ordering, and pagination, then converts it to a raw SQL string.
Always ensure that any data passed into `raw()` functions is either hardcoded or strictly sanitized/parameterized if derived from user input. Prefer using the type-safe builder methods where possible.
Consult your specific database's documentation for non-standard features. Employ `raw()` for such constructs, carefully testing the generated SQL against your target database.
For complex `raw()` expressions with aliases, consider defining explicit interfaces or types for the result set, or use type assertions (`as MyResultType`) where the type inference might fall short to maintain strict type safety.
Ensure the column name exactly matches a property in the interface provided to `table<T>`, or add the missing property to the interface.
Use ES Module `import` syntax: `import { select, column } from 'sql-select-ts';`Ensure `select` is imported as a named export: `import { select } from 'sql-select-ts';` (not `import select from 'sql-select-ts'`).No dependency data recorded yet.