Dramatically simple SQL Builder for Node.js
Simple opinionated SQL builder under 200 lines of code.
Prepares query predicates with placeholders like ":variable" to be used with appropriate query substitutors.
Unlike other wrappers, dram-sql heavily relies on object data processing, and driven by a single properties object meant to be bound to the query on the execution time.
Features
- Lightweight
- Object-driven
Install
npm install dram-sql --save
Usage with node-mysql2
node-mysql2 has built-in substitution for :variable placeholders
var driver = ; var connection = ... namedPlaceholders: true var db = driver; var params = id: 45 email: 'den@example.com'; db;
)
Also see examples below.
Syntax
var sql = ; var props = id: 45 email: 'den@example.com'; var anotherProsp = toselect: 88; >>> SELECT toselect FROM table1 WHERE ; -------------- ';' ; -- close the parenthesis
Dependencies
Licese
MIT