29 lines
490 B
JavaScript
29 lines
490 B
JavaScript
|
|
var Dml = require('./dml');
|
|
|
|
/**
|
|
* The equivalent of a SQL update.
|
|
*/
|
|
module.exports = new Class({
|
|
Extends: Dml
|
|
|
|
,render: function(params) {
|
|
var sql = 'UPDATE'
|
|
+ this.renderTarget(params)
|
|
+ ' SET ';
|
|
|
|
this.field.forEach(function(field, i) {
|
|
if (i > 0)
|
|
sql += ', ';
|
|
|
|
sql += field.render(params)
|
|
+ ' = '
|
|
+ this.expr[i].render(params);
|
|
}, this);
|
|
|
|
sql += this.renderIfSet(this.where, 'WHERE', params)
|
|
+ this.renderLimit(params);
|
|
return sql;
|
|
}
|
|
});
|