不要怂,就是干,撸起袖子干!

Commit 36d748f4 by sdepold

more query interface stuff

1 parent 5b96de26
Showing with 4 additions and 5 deletions
......@@ -72,8 +72,6 @@ module.exports = (function() {
}
ModelFactory.prototype.max = function(field, options) {
var self = this
var emitter = new Utils.CustomEventEmitter(function() {
query.call(self, self.QueryGenerator.maxQuery(self.tableName, field,options), self, {plain: true}).success(function(obj) {
emitter.emit('success', obj['max'])
......@@ -91,8 +89,9 @@ module.exports = (function() {
})
return emitter.run()
}
ModelFactory.prototype.findAll = function(options) {
return query.call(this, this.QueryGenerator.selectQuery(this.tableName, options))
return this.QueryInterface.select(this, this.tableName, options)
}
ModelFactory.prototype.find = function(options) {
......
......@@ -64,10 +64,10 @@ module.exports = (function() {
options = options || {}
options.attributes = options.attributes || []
options.attributes.push('count(*) as count')
options.attributes.push(['count(*)', 'count'])
return new Utils.CustomEventEmitter(function(emitter) {
var sql = self.QueryGenerator.selectQuery(tableName, options).replace('`' + countOption + '`', countOption)
var sql = self.QueryGenerator.selectQuery(tableName, options)
query.call(self, sql, factory, { plain: true }).success(function(data) {
emitter.emit('success', data.count)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!