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

Commit e44990e9 by Michael Schonfeld Committed by Michael Schonfeld

add sum() finder functionality to DAOFactory

1 parent e70d354f
Showing with 8 additions and 0 deletions
...@@ -620,6 +620,14 @@ module.exports = (function() { ...@@ -620,6 +620,14 @@ module.exports = (function() {
return this.aggregate(field, 'min', options) return this.aggregate(field, 'min', options)
} }
DAOFactory.prototype.sum = function(field, options) {
options = Utils._.extend({ attributes: [] }, options || {})
options.attributes.push(['sum(' + this.QueryInterface.QueryGenerator.quoteIdentifier(field) + ')', 'sum'])
options.parseFloat = true
return this.QueryInterface.rawSelect(this.getTableName(), options, 'sum')
}
DAOFactory.prototype.build = function(values, options) { DAOFactory.prototype.build = function(values, options) {
options = options || { isNewRecord: true, isDirty: true } options = options || { isNewRecord: true, isDirty: true }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!