Registry / database / xsql
library1.0.1jsnpmunverified

XSQL is a SQL query builder library for Node.js supporting MySQL, MariaDB, SQLite, and PostgreSQL dialects. Version 1.0.1 provides a programmatic API to construct SQL queries using helper methods like x.select(), x.from(), x.where(), and x.join(). It handles identifier quoting, table aliasing, and schema prefixes per dialect. The library is minimal, has no dependencies, and focuses on building SELECT, INSERT, UPDATE, DELETE queries with nested functions, joins, and conditions. Released under MIT license, it receives infrequent updates. Compared to knex.js or squel, XSQL is lighter but requires more manual query assembly via string concatenation.

npm install xsql
INSTALL
IMPORT
SIG · XSQL
X
xsql
databasejavascriptv1.0.1
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 Xsql from 'xsql'
const Xsql = require('xsql')
Package provides ESM default export; CommonJS require works but TypeScript may need esModuleInterop.
constructor
const x = new Xsql({dialect: 'mysql'})
Constructor accepts dialect and optional schema. Instance methods are used to build queries.
types (TypeScript)
import type { XsqlInstance } from 'xsql'
import { Xsql } from 'xsql'
No named type exports; use default for runtime and typeof for types if needed.

Constructs a SELECT query with columns and WHERE condition, outputting quoted identifiers for MySQL.

import Xsql from 'xsql' const x = new Xsql({dialect: 'mysql'}) const query = [ x.select(x.names(['col1','col2'],'tbl')), x.from(x.name('tbl')), x.where(x.eq(x.name('id','tbl'),2)), ';' ].join(' ') console.log(query) // Output: select `tbl`.`col1`,`tbl`.`col2` from `tbl` where `tbl`.`id`=2 ;
Debug
Known issues
gotchaAll methods must be called as instance methods; forgetting 'new' when constructing leads to errors.
fix
Always call new Xsql({...}) before using method chaining.
affects: >=1.0.0
gotchaCannot use named imports; only default export is available.
fix
Use import Xsql from 'xsql' instead of destructuring.
affects: >=1.0.0
deprecatedNo deprecation notices yet. The package is stable but receives infrequent updates.
fix
Consider knex.js or squel for active maintenance and more features.
affects: >=1.0.0
gotchaIdentifier quoting varies by dialect; explicit dialect must be provided.
fix
Pass dialect option: 'mysql', 'mariadb', 'sqlite', 'postgresql', or 'pg'.
affects: >=1.0.0
gotchaSchema prefixes are ignored on non-PostgreSQL dialects; using x.schema('z') on MySQL produces no prefix.
fix
Only use schema with 'pg' or 'postgresql' dialect.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Xsql is not a constructor
Using named import instead of default import, or failing to use 'new'.
fix
import Xsql from 'xsql'; const x = new Xsql({dialect:'mysql'});
Cannot find module 'xsql'
Package not installed or not in node_modules.
fix
npm install xsql
TypeError: x.select is not a function
Instance not created with 'new' or using namespace instead of instance.
fix
Ensure calling new Xsql() and storing result in a variable.
Unclosed quotation mark
String literals in SQL not properly escaped; x.wrap() only for identifiers.
fix
Use x.escape() for values, or manually add quotes with proper escaping.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
20
Meta
1
OpenAI (training)
1
Resources
packagexsql
xsql — npm install xsql · libregistry