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

Commit e6c91420 by Mick Hansen

continue to support transactions

1 parent 898b76d7
Showing with 3 additions and 7 deletions
......@@ -566,18 +566,14 @@ module.exports = (function() {
}
DAOFactory.prototype.count = function(options) {
/*options = Utils._.extend({ attributes: [] }, options || {})
options.dataType = DataTypes.INTEGER
return this.aggregate('*', 'count', options)*/
options = Utils._.clone(options || {})
return new Utils.CustomEventEmitter(function (emitter) {
options.attributes = [
[this.sequelize.fn('COUNT', this.sequelize.col(this.tableName+'.*')), 'count']
]
options.includeIgnoreAttributes = false
this.find(options, {raw: true}).proxy(emitter, {events: ['sql', 'error']}).success(function (result) {
this.find(options, {raw: true, transaction: options.transaction}).proxy(emitter, {events: ['sql', 'error']}).success(function (result) {
emitter.emit('success', parseInt(result.count, 10))
})
}.bind(this)).run()
......
......@@ -580,7 +580,7 @@ Utils.fn.prototype.toString = function(queryGenerator) {
}
Utils.col.prototype.toString = function (queryGenerator) {
if (this.col === '*') return '*'
if (this.col.indexOf('*')) return '*'
return queryGenerator.quote(this.col)
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!