0
1
Fork 0
hedera-web-mindshore/js/sql/select.js

38 lines
579 B
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
var Stmt = require ('./stmt');
var Field = require ('./field');
/**
* The equivalent of a SQL select.
**/
2016-09-26 09:28:47 +00:00
module.exports = new Class
({
2016-09-26 09:28:47 +00:00
Extends: Stmt
,expr: []
,addField: function (fieldName)
{
2016-09-26 09:28:47 +00:00
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;
}
});