Use connector's buildWhere to implement count

This commit is contained in:
Raymond Feng 2014-06-01 09:14:42 -07:00
parent 653aab856c
commit 3e8284d1ee
1 changed files with 7 additions and 1 deletions

View File

@ -292,8 +292,14 @@ BaseSQL.prototype.count = function count(model, callback, where) {
var self = this;
var props = this._models[model].properties;
var whereClause = '';
if (typeof this.buildWhere === 'function') {
whereClause = this.buildWhere(model, where);
} else {
whereClause = buildWhere(where);
}
this.queryOne('SELECT count(*) as cnt FROM ' +
this.tableEscaped(model) + ' ' + buildWhere(where), function (err, res) {
this.tableEscaped(model) + ' ' + whereClause, function (err, res) {
if (err) {
return callback(err);
}