Registry / database / sql-love

sql-love

JSON →
library1.1.0jsnpmunverified

sql-love (v1.1.0) provides classes for parsing and building SQL SELECT queries in Node, Bun, and Deno. It supports dynamic adding of clauses (JOIN, WHERE, ORDER BY, LIMIT, OFFSET), named placeholders, and prepared statement binding arrays. Unlike other SQL builders, it can parse existing SQL strings as base queries. It is written in TypeScript, zero-dependency, tree-shakeable, and features utility functions for pagination, grouping, and safe JSON extraction. Released under ISC license.

npm install sql-love
INSTALL
IMPORT
SIG · SQL-LOVE
S
sql-love
databasejavascriptv1.1.0
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.

SelectBuilder
import { SelectBuilder } from 'sql-love'
const SelectBuilder = require('sql-love')
ESM-only import; no CommonJS support.
SelectBuilder
import { SelectBuilder } from 'sql-love'
import SelectBuilder from 'sql-love'
Named export, not default.
getPagination
import { getPagination } from 'sql-love'
import { getPagination } from 'sql-love/utilities'
All utilities are re-exported from the main entry.

Shows how to parse a base SELECT query, dynamically add WHERE, ORDER BY, and LIMIT clauses, and compile to SQL with bindings.

import { SelectBuilder } from 'sql-love'; const query = new SelectBuilder(` SELECT u.id, u.fname, u.lname FROM users u WHERE u.is_active = 1 `); query.where('u.email', process.env.EMAIL ?? ''); query.sort('u.fname'); query.limit(10); const { sql, bindings } = query.compile(); console.log(sql); console.log(bindings); // Example with Prisma: // const result = await prisma.$queryRawUnsafe(sql, ...bindings);
Debug
Known issues
gotchaIdentifiers in SQL strings are not parameterized; user input in identifiers can lead to SQL injection.
fix
Use your SQL client's `quoteIdentifier()` function for dynamic column/table names.
affects: >=0.0.0
deprecatedThe `SelectBuilder` constructor with named placeholders is experimental and may change.
fix
Use the formal `new SelectBuilder(sql, params)` signature; avoid relying on undocumented placeholder syntax.
affects: >=1.0.0 <2.0.0
gotchaParser limitations: subqueries, UNION, and CTEs are not supported in base SQL string.
fix
Manually construct complex queries or use raw SQL strings outside of SelectBuilder.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'sql-love'
Package not installed or incorrect import path.
fix
Run `npm install sql-love` and ensure your import is `import { SelectBuilder } from 'sql-love'`.
TypeError: sql_love_1.SelectBuilder is not a constructor
Using CommonJS require() on an ESM-only package.
fix
Use ESM import syntax or set `"type": "module"` in your package.json.
SyntaxError: Unexpected token 'export'
Running CommonJS Node without proper ESM support.
fix
Use `--input-type=module` flag or rename file to .mjs.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
10
Meta
2
OpenAI (training)
1
Resources
sql-love — npm install sql-love · libregistry