0.0.2 • Published 6 years ago

node-sqlloader v0.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

node-sqlloader

A handy node module to get SQL out of your code and into .sql files.

Typical usage

const sqlLoader = require( "node-sqlloader");

sqlLoader.load( "./sql/*.sql", function( err, sql) {
    global.g_sql = sql;

    db.query( g_sql.getUsers, function... );
})

SQL File Format

Basically a SQL statement starts with a C-style comment with the name of the statement, following by the statement, and ending with a semicolon.

A nice benefit of this is that the SQL can be pasted into your favourite SQL editor (SQLYog) without any changes.

/*testOne*/
Select firstname from user where id=1;

/*testTwo*/
Select firstname
from user
inner join hobbies on hobbies.userID = user.id
where id=1
;

Enjoy!