Registry / database / marciemarc425-waterline-sql-builder

marciemarc425-waterline-sql-builder

JSON →
library3.0.6jsnpmunverified

Generates SQL (stage 5 query) from a Waterline statement (stage 4 query) for Sails/Waterline SQL adapter authors. v3.0.6 is the current stable version; built on top of knex, supports PostgreSQL, MySQL, Oracle, and MSSQL dialects. Not backwards compatible with Waterline-Sequel. Release cadence is irregular. Key differentiator: standardizes SQL generation across SQL adapters in the Waterline ecosystem, replacing the older Waterline-Sequel library. Used internally by core Sails adapters.

npm install marciemarc425-waterline-sql-builder
INSTALL
IMPORT
SIG · MARCIEMARC425-WATE
M
marciemarc425-waterline-sql-builder
databasejavascriptv3.0.6
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.

SQLBuilder
const SQLBuilder = require('waterline-sql-builder');
import SQLBuilder from 'waterline-sql-builder';
This package uses CommonJS; ESM import is not supported natively (may work with bundlers but not guaranteed).
generate
const sqlBuilder = SQLBuilder({ dialect: 'postgres' }); const result = sqlBuilder.generate(statement);
const { generate } = require('waterline-sql-builder')({ dialect: 'postgres' });
`.generate` is a method on the instance returned by `SQLBuilder(options)`, not a standalone export.
SQLBuilder (ESM workaround)
const SQLBuilder = require('waterline-sql-builder').default;
import SQLBuilder from 'waterline-sql-builder';
If using TypeScript with `esModuleInterop` or bundlers, the default import may be available via `.default`. Check your setup.

Demonstrates basic usage: create a SQLBuilder instance for PostgreSQL, compile a Waterline statement, and output the SQL template and bindings array.

const SQLBuilder = require('waterline-sql-builder'); const compile = SQLBuilder({ dialect: 'postgres' }).generate; const statement = { select: ['id', 'name'], where: { email: 'test@example.com', age: { '>': 18 } }, from: 'users' }; const report = compile(statement); console.log(report.sql); console.log(report.bindings);
Debug
Known issues
breakingThis package is NOT backwards compatible with waterline-sequel. Statements must follow the stage 4 query spec.
fix
Update adapter code to use new Waterline statement format as described in https://github.com/balderdashy/waterline/blob/88bdfac31844e367a979661c4232fd5f521f3a33/ARCHITECTURE.md#stage-4-query
affects: >=3.0.0
gotchaThe package requires knex as a peer dependency. Ensure knex is installed and compatible.
fix
Run `npm install knex` alongside waterline-sql-builder.
affects: >=1.0.0
deprecatedUsing Waterline statements from app-level code is experimental and may break with minor or major version bumps.
fix
Only use this package in adapter code; for app-level queries, use Waterline's model methods.
affects: >=3.0.0
gotchaDialect must be one of: 'postgresql', 'postgres', 'mysql', 'oracle', 'mssql'. Case-sensitive.
fix
Provide a valid dialect string. For PostgreSQL, either 'postgresql' or 'postgres' works.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'knex'
knex is a peer dependency not automatically installed.
fix
npm install knex
TypeError: SQLBuilder is not a constructor
Using ES6 import syntax that does not resolve to default export correctly.
fix
Use CommonJS require: const SQLBuilder = require('waterline-sql-builder');
Error: Invalid dialect 'sqlite'
Only PostgreSQL, MySQL, Oracle, MSSQL are supported.
fix
Use one of the supported dialects: 'postgresql', 'postgres', 'mysql', 'oracle', 'mssql'.
Upgrade
Version history
3.0.6latest on npm
Audit
Dependencies
knexrequiredCore SQL query compilation engine; knex is used to build and parameterize SQL strings.
Agent activity
8 hits · last 30 days
node
8
Resources
marciemarc425-waterline-sql-builder — npm install marciemarc425-waterline-sql-builder · libregistry