Registry / database / squel
library6.0.7jsnpmunverified

A flexible SQL query string builder for JavaScript and TypeScript, currently at version 6.0.7. It supports standard SQL queries (SELECT, UPDATE, INSERT, DELETE) and non-standard commands for MySQL, PostgreSQL, and Microsoft SQL Server. Features include fluent method-chaining, parameterized queries for safe value escaping, and first-class TypeScript support. Squel is suitable for production, works in Node.js and the browser, and ships as dual ESM + CommonJS with an IIFE bundle for CDN use. Major releases have broken changes: v5 removed the 'squel.flavours' namespace and v6 dropped Node <18. Alternatives include Knex for richer ORM features.

npm install squel
INSTALL
IMPORT
SIG · SQUEL
S
squel
databasejavascriptv6.0.7
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.

default
import squel from 'squel'
const squel = require('squel')
ESM-style import; works in TypeScript and modern JavaScript. For CommonJS, use const squel = require('squel').default (or const { squel } = require('squel')).
select
import { select } from 'squel'
const select = squel.select
Named export available in v6. You can also use squel.select() via default import.
express
import { express } from 'squel'
const express = require('squel-express')
The express() function creates a squel instance with custom options (e.g., autoQuoteFieldNames). It's a named export from squel itself, not a separate package.

Shows basic SELECT query building with squel, including parameterization and MySQL flavour.

import squel from 'squel'; const query = squel.select() .from('books') .field('title') .where("author = ?", 'J.K. Rowling') .toString(); console.log(query); // Output: SELECT title FROM books WHERE (author = 'J.K. Rowling') // Parameterized version: const paramQuery = squel.select() .from('books') .field('title') .where('author = ?', 'J.K. Rowling') .toParam(); console.log(paramQuery.text); // Output: SELECT title FROM books WHERE (author = $1) or ? depending on dialect // MySQL dialect import squel from 'squel'; const mysql = squel.useFlavour('mysql'); const mysqlQuery = mysql.select().from('users').field('id').toString(); console.log(mysqlQuery); // SELECT `id` FROM `users`
Debug
Known issues
breakingIn v6, the default import changed. Previously, require('squel') returned the squel object directly. In v6, require('squel') returns an object with a default property. Use require('squel').default or the ES import.
fix
Use import squel from 'squel' (ESM) or const squel = require('squel').default (CommonJS).
affects: >=6.0.0
breakingsquel.flavours is removed. In v5, you could do squel.flavours.mysql. In v6, use squel.useFlavour('mysql').
fix
Replace squel.flavours.mysql with squel.useFlavour('mysql').
affects: >=6.0.0
breakingNode.js 18+ is required. Older versions of Node.js (e.g., 14, 16) are no longer supported.
fix
Upgrade Node.js to version 18 or later.
affects: >=6.0.0
deprecatedThe .having() method is deprecated in favor of .where() with a HAVING clause. Or use the .having() from the MySQL flavour if needed.
fix
Replace .having('condition') with .where('condition') and ensure the query uses HAVING context.
affects: >=6.0.0
Errors
Common errors & fixes
Cannot read properties of undefined (reading 'select')
Using require('squel') without accessing .default in v6.
fix
Use const squel = require('squel').default; or switch to ES import.
squel.flavours is undefined
In v6, squel.flavours is removed; use squel.useFlavour().
fix
Replace squel.flavours.mysql with squel.useFlavour('mysql').
require(...).default is not a function
Previously in v5, require('squel') returned the squel object directly. In v6, you must call .default.
fix
Change require('squel') to require('squel').default, or use ESM import.
Cannot find module 'squel'
npm package not installed or old Node version not supporting ESM resolve.
fix
Run npm install squel, ensure Node.js >=18.
Upgrade
Version history
6.0.7latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Meta
1
OpenAI (training)
1
Resources
packagesquel
squel — npm install squel · libregistry