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

33 lines
527 B
JavaScript
Raw Normal View History

2016-09-26 09:28:47 +00:00
var Dml = require ('./dml');
/**
* The equivalent of a SQL update.
2022-05-26 06:08:31 +00:00
*/
2016-09-26 09:28:47 +00:00
module.exports = new Class
({
2016-09-26 09:28:47 +00:00
Extends: Dml
,render: function (batch)
{
var sql;
var n;
sql = 'UPDATE ' + this.renderTarget (batch) + ' SET ';
for (n = 0; n < this.field.length; n++)
{
if (n > 0)
sql += ', ';
sql += this.field[n].render () + ' = ' + this.expr[n].render(batch);
}
if (this.where)
sql += ' WHERE ' + this.where.render (batch);
sql += ' LIMIT 1'; // Only for security.
return sql;
}
});