var GrammarTemplate = require("../src/js/GrammarTemplate.js"), echo = console.log;
echo('GrammarTemplate.VERSION = ' + GrammarTemplate.VERSION);
echo( );
var tpl = "SELECT <column.select>[, <*column.select>]\nFROM <table.from>[, <*table.from>][\nWHERE (<?required.where>) AND (<?condition.where>)][\nWHERE <?required.where><?!condition.where>][\nWHERE <?!required.where><?condition.where>][\nGROUP BY <?group>[, <*group>]][\nHAVING (<?required.having>) AND (<?condition.having>)][\nHAVING <?required.having><?!condition.having>][\nHAVING <?!required.having><?condition.having>][\nORDER BY <?order>[, <*order>]][\nLIMIT <offset|0>, <?count>]";
var sql = new GrammarTemplate( tpl );
echo("input template:");
echo(tpl);
echo( );
echo("output:");
echo(sql.render({
column : { select : [ 'field1', 'field2', 'field3', 'field4' ] },
table : { from : [ 'tbl1', 'tbl2' ] },
condition : { where : 'field1=1 AND field2=2', having : 'field3=1 OR field4=2' },
count : 5
}));
|