Use connector's buildWhere to implement count
This commit is contained in:
parent
653aab856c
commit
3e8284d1ee
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue