Create your SQL more easily.
squeal - Create your SQL like a boss.
var squeal = require'squeal'// Returns an object which has various methods.// Only requires 'pk' and 'name' to be provided.var account = squealpk : 'id'name : 'account'ro : 'id' 'inserted' 'updated'rw : 'username' 'email' 'password'// do a regular select (with no where clause)var stmt = accountselconsole.log'sql=' + stmtsql// -> SELECT id, inserted, updated, username, email, password FROM account;// select just 'id' and 'username' where 'email = "email@example.com"'var stmt = accountselwhere :email : 'firstname.lastname@example.org'console.log'sql=' + stmtsql// -> SELECT id, username FROM account WHERE email = $1console.log'sql=' + stmtvals// -> 'email@example.com'
Squeal can also help you construct bigger SQL statements such as when you are joining tables, though squeal doesn't actually do this for you (since you know your data better than it does). For example, if joining a item table with an account table.
Written by Andrew Chilton: