require-sql
v1.0.0
Published
Allows for storing and using SQL files via require()
Downloads
5,729
Readme
node-require-sql
Allows for files with .sql extensions to be used with queries stored as plain text (no javascript multiline string non-sense).
Basic Example
// some-file.sql
SELECT
*
FROM
my_table
require('require-sql');
var query = require('./some-query.sql');
Template Example
An example using Underscore.js to insert variables using the template function.
// some-query-with-params.sql
SELECT
*
FROM
my_table
WHERE
name = <%- name %>
var __ = require('underscore');
require('require-sql');
var query = require('./some-query-with-params.sql');
var queryWithParameters = __.template(query, {name: 'Bob'});