statements
Meet statements
. An elegantly simple SQL statement utilty for Node.js.
statements
lets you write SQL in a raw file. You simply delimit each SQL statement with a comment. statements
will use the contents of that comment as the object key.
Getting started
npm install statements
-- createTable
CREATE TABLE environment (
idenvironment INTEGER PRIMARY KEY AUTOINCREMENT,
name NVARCHAR(255) NOT NULL,
description TEXT
);
-- selectById
SELECT environment where idenvironment = $id;
// load the modulevar statements = ; // read the contents of a file into an objectvar sql = statements; // do something with the valuesdb;db;
Options
Statements supports sync and async.
read(file, callback)
file - required callback - node style callback
Performs a sync operation if no callback is specified. Will return the result when run in synchronous mode.
readAsync(file, callback)
file - required callback - optional node style callback
Executes the load asynchronously and return a promise and optionally calls the callback. The result will be an object
readSync(file)
file - required
Performs a sync operation. Will return the result when run in synchronous mode.
Contributing
In leui of a style-guide please follow existing patterns and add appropriate unit tests.
You can validate your code with grunt validate