A flexible SQL query fragment builder for Node.js that generates partial or full SQL queries. Current stable version is 0.5.6, released on an irregular cadence. It supports custom types, compound column expansion (e.g., addresses becoming multiple columns), and join/collation utilities. Unlike full ORMs, it focuses on composing fragments for tedious parts like field lists, leaving full query control to the developer. It includes validation and fill features for records, and supports PostgreSQL and MySQL dialects.
npm install sql-motifNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a table, joins another table, and generates a SELECT query with a WHERE clause.
Ensure motif = require('sql-motif')({ types, dialect });Use valid dialect string like 'mysql', 'postgresql', or omit for default.
Use join.selectWhere() if you need SELECT keyword in output.
Ensure type names match exactly, e.g., 'addressLine' not 'addressline'.
Define compound types carefully and use them only in table definitions.
const instance = require('sql-motif')({ types: {} }); const orders = new instance.Table({...});Pass { dialect: 'mysql' } or { dialect: 'postgresql' } to factory.Install and import uuid: const uuid = require('uuid'); then use it in type definitions.