Registry / database / genql
library2.0.1jsnpmunverified

GenQL is a lightweight SQL query generation and formatting library for Node.js, designed to simplify dynamic SQL construction using model definitions. It is currently at version 2.0.1, with a stable release cadence. Unlike full-featured ORMs or query builders like Knex or Sequelize, GenQL focuses on generating SELECT, INSERT, and UPDATE queries based on a JSON model that defines fields, defaults, aliases, and private flags. It supports optional field prefixes, automatic exclusion of private or auto-generated columns, and offers helpers for value extraction and privacy filtering. Suitable for small to medium projects where a minimal, model-driven SQL helper is preferred over heavy abstractions. It is not actively maintained; the last release and commit were in 2019, and Travis CI badge indicates legacy infrastructure.

npm install genql
INSTALL
IMPORT
SIG · GENQL
G
genql
databasejavascriptv2.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.

GenQL
const GenQL = require('genql')
GenQL is a CommonJS library. It does not provide native ESM exports. A dynamic import (import('genql')) is possible but not the default.
GenQL (ESM)
import GenQL from 'genql'
const { GenQL } = require('genql')
Default import via ESM works only if your environment supports dynamic imports, but the library is CJS. The named destructure will be undefined.
GenQL class
const $ = new GenQL(model)
new GenQL() without model
The constructor requires a model object. Using it without parameters will cause errors because internal methods expect the model.

Shows instantiation with a JSON model and using _select to get field names with optional prefix.

const GenQL = require('genql'); const model = { table: 'users', columns: [ { name: 'id', type: 'integer', auto: true }, { name: 'name', type: 'string' }, { name: 'email', type: 'string' }, { name: 'class', type: 'string', alternate: "COALESCE(NULLIF(class, ''), 'cls')" }, { name: 'status', type: 'string' } ] }; const $ = new GenQL(model); console.log($._select()); console.log($._select('$'));
Debug
Known issues
gotchaLibrary expects a specific model structure with 'columns' array; missing or malformed model will throw errors at runtime.
fix
Ensure model has table and columns properties as shown in the quickstart or the sample model.json.
affects: >=0.0.0
gotchaMethods like _insert and _values treat fields with 'auto' flag as private and exclude them; not documented clearly.
fix
Mark auto-increment fields with 'auto: true' to automatically exclude from INSERT queries.
affects: >=0.0.0
deprecatedThe library is unmaintained since 2019; no updates for modern Node.js versions (e.g., ESM, async/await patterns).
fix
Consider migrating to actively maintained query builders like Knex or Prisma for new projects.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: Cannot read property 'columns' of undefined
Calling methods on GenQL instance without passing a model to the constructor.
fix
Pass a valid model object: new GenQL({ table: '...', columns: [...] });
GenQL is not defined
Using require('genql') incorrectly or assuming default export in old Node/CommonJS.
fix
Use const GenQL = require('genql'); (CommonJS) or import GenQL from 'genql' (ESM if supported).
Upgrade
Version history
2.0.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
packagegenql
genql — npm install genql · libregistry