forked from verdnatura/hedera-web
38 lines
578 B
JavaScript
38 lines
578 B
JavaScript
|
|
var Stmt = require ('./stmt');
|
|
var Field = require ('./field');
|
|
|
|
/**
|
|
* The equivalent of a SQL select.
|
|
*/
|
|
module.exports = new Class
|
|
({
|
|
Extends: Stmt
|
|
|
|
,expr: []
|
|
|
|
,addField: function (fieldName)
|
|
{
|
|
this.expr.push (new Field ({name: fieldName}));
|
|
}
|
|
|
|
,render: function (batch)
|
|
{
|
|
var sql = 'SELECT '
|
|
|
|
for (var i = 0; i < this.expr.length; i++)
|
|
{
|
|
if (i > 0)
|
|
sql += ', ';
|
|
sql += this.expr[i].render(batch);
|
|
}
|
|
|
|
sql += ' FROM ' + this.renderTarget (batch);
|
|
|
|
if (this.where)
|
|
sql += ' WHERE ' + this.where.render (batch);
|
|
|
|
return sql;
|
|
}
|
|
});
|