diff --git a/lib/sql.js b/lib/sql.js index 1777602e..23e4c741 100644 --- a/lib/sql.js +++ b/lib/sql.js @@ -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); }