Registry / database / sql-easy-builder

sql-easy-builder

JSON →
library3.3.0jsnpmunverified

sql-easy-builder is a lightweight SQL query builder for Node.js that supports SELECT, INSERT, UPDATE, DELETE, JOINs, subqueries, and common SQL functions with a fluent API. Version 3.3.0 is stable with active maintenance. It differentiates itself by offering a simple, chainable syntax, automatic parameterized queries to prevent SQL injection, TypeScript type definitions, and zero dependencies. Unlike heavier ORMs, it provides fine-grained control over SQL generation without abstracting away the database language.

npm install sql-easy-builder
INSTALL
IMPORT
SIG · SQL-EASY-BUILDER
S
sql-easy-builder
databasejavascriptv3.3.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.

Builder
import { Builder } from 'sql-easy-builder'
import Builder from 'sql-easy-builder'
Builder is a named export, not default. For CJS: const { Builder } = require('sql-easy-builder').
raw
import { raw } from 'sql-easy-builder'
import { raw } from 'sql-easy-builder'
raw is a named export used for escaping table/column names in raw SQL fragments.
SQL
import { SQL } from 'sql-easy-builder'
import SQL from 'sql-easy-builder'
SQL is a tagged template literal function, exported as a named export. Use: SQL`SELECT * FROM {table}`.

Demonstrates a SELECT query with alias, WHERE, ORDER DESC, and parameterized LIMIT using Builder's fluent API.

import { Builder, raw } from 'sql-easy-builder'; const builder = new Builder(); const { query, values } = builder .select('id', 'name', { age: 'user_age' }) .from('users', 'u') .where({ 'u.status': 'active' }) .order('-u.created_at') .limit(10) .build(); console.log(query); // SELECT `id`, `name`, `age` AS `user_age` FROM `users` AS `u` WHERE `u`.`status` = ? ORDER BY `u`.`created_at` DESC LIMIT ? console.log(values); // ['active', 10]
Debug
Known issues
gotchaColumn names containing dots are treated as table.column references if not escaped with raw().
fix
Use raw() or avoid dots in column aliases unless you intend table qualification.
affects: <=3.3.0
gotchaThe build() method returns an object with 'query' and 'values', not a single string.
fix
Always destructure: const { query, values } = builder.build();
affects: *
gotchaMethods like select(), where() etc. mutate the builder instance; reuse requires a new Builder.
fix
Create a new Builder() for each query or clone if needed.
affects: *
gotchaThe where() clause with an object does not support OR conditions; use raw or multiple where calls?
fix
For OR, chain where with raw() or consult documentation.
affects: *
gotchaBoolean values in where() are not converted; pass 1/0 or use raw() for true/false columns.
fix
Use { active: 1 } instead of { active: true }.
affects: *
Errors
Common errors & fixes
TypeError: Builder is not a constructor
Default import used instead of named import.
fix
Use import { Builder } from 'sql-easy-builder';
Cannot find module 'sql-easy-builder'
Package not installed or import path incorrect.
fix
Run: npm install sql-easy-builder
Property 'build' does not exist on type 'Builder'
Using TypeScript but may need to check typings or version mismatch.
fix
Ensure sql-easy-builder version >=3.0.0 and tsconfig includes node_modules types.
Upgrade
Version history
3.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
28 hits · last 30 days
node
24
Meta
1
OpenAI (training)
1
Resources
sql-easy-builder — npm install sql-easy-builder · libregistry