Registry / database / squel-ts

squel-ts

JSON →
library1.1.5jsnpmunverified

squel-ts (v1.1.5) is a TypeScript and ESM fork of the abandoned squel SQL query builder library. It provides a flexible, zero-dependency query string builder for SQL databases, supporting SELECT, INSERT, UPDATE, DELETE, and engine-specific commands (MySQL etc.) via a fluent, chainable API. Released as a maintenance fork, it targets modern Node.js (>=12) and browsers, with built-in TypeScript definitions. Unlike Knex, it generates raw query strings without requiring a connection, making it lightweight for embedding. Release cadence is low; consider it in maintenance mode.

npm install squel-ts
INSTALL
IMPORT
SIG · SQUEL-TS
S
squel-ts
databasejavascriptv1.1.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

select
import { select } from 'squel-ts'
import select from 'squel-ts'
select is a named export, not default. Common mistake from original squel CJS pattern.
squel (namespace)
import * as squel from 'squel-ts'
const squel = require('squel-ts')
ESM-only module; require() will fail. Use dynamic import() if needed.
update / insert / remove
import { update, insert, remove } from 'squel-ts'
import { update, insert, delete } from 'squel-ts'
DELETE query builder is exported as 'remove' (not 'delete') to avoid JS reserved word.
QueryBuilder types
import type { QueryBuilder, SelectQueryBuilder } from 'squel-ts'
Type-only imports are safe but not strictly required since the library ships TypeScript types.

Builds a SELECT query with field aliasing, filtering, ordering, and pagination. Shows both raw and parameterized output.

import { select, insert, update, remove } from 'squel-ts'; // SELECT const query = select() .from('users') .field('id', 'userId') .field('name') .where("age > ?", 18) .order('name', true) .limit(10) .toString(); console.log(query); // SELECT id AS "userId", name FROM users WHERE (age > 18) ORDER BY name ASC LIMIT 10 // Parameterized const param = select() .from('users') .where("status = ?", 'active') .toParam(); console.log(param); // { text: 'SELECT * FROM users WHERE (status = ?)', values: ['active'] }
Debug
Known issues
breakingsquel-ts is ESM-only and does not support CommonJS require(). Direct require() will throw a MODULE_NOT_FOUND error.
fix
Use ESM imports: import { ... } from 'squel-ts' or dynamic import('squel-ts').
affects: >=1.0.0
breakingDELETE queries are built via the exported `remove` function, not `delete`. Using `delete` will cause a ReferenceError in strict mode.
fix
Import and use remove({...}) instead of delete({...}).
affects: >=1.0.0
gotchaField names are not automatically quoted unless `autoQuoteFieldNames` option is enabled. Without quoting, field names with special characters can produce invalid SQL.
fix
Pass `{ autoQuoteFieldNames: true }` to the query builder constructor, e.g., select({ autoQuoteFieldNames: true }).
affects: all
deprecatedThe original squel library is abandoned. squel-ts is a TypeScript fork with API refinements; some edge cases may differ.
fix
Upgrade to squel-ts and consult CHANGELOG for breaking changes. The API is largely compatible.
affects: <1.0.0
gotchaBulk Insert key order is not guaranteed. When inserting multiple rows, the order of columns in the resulting SQL may vary across objects, causing misalignment.
fix
Ensure all objects in a bulk insert have the same property order, or use explicit field() calls.
affects: all
Errors
Common errors & fixes
const squel = require('squel-ts')
squel-ts is ESM-only; require() is not supported.
fix
Use 'import * as squel from "squel-ts"' or 'const squel = await import("squel-ts")'.
import select from 'squel-ts' // TypeError: squel_ts_1.default is not a function
Default export does not exist; all builders are named exports.
fix
Use 'import { select } from "squel-ts"'.
squel.delete() is not a function
DELETE builder is exported as 'remove' to avoid JS reserved word.
fix
Use 'import { remove } from "squel-ts"' or 'squel.remove()'.
Cannot find module 'squel-ts' or its corresponding type declarations.
TypeScript may not resolve ESM modules correctly without 'moduleResolution' set to 'node16' or 'bundler'.
fix
Set 'moduleResolution' to 'node16' or 'bundler' in tsconfig.json, or use '--moduleResolution node16'.
Expected 0 arguments, but got 1.
Calling select(options) or similar constructor with object argument not allowed? Actually squel-ts does accept options; error may arise if importing wrong symbol.
fix
Check import: use 'select' from 'squel-ts', not 'Squel' or other internal class.
Upgrade
Version history
1.1.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources