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

Commit a2432384 by Jan Aagaard Meier

Cleanup in 830

2 parents ff6a3576 ba3cfab3
Showing with 6 additions and 12 deletions
......@@ -354,15 +354,8 @@ module.exports = (function() {
DAOFactory.prototype.findAndCountAll = function(options) {
var self = this
, opts = Utils._.cloneDeep(options)
, copts = Utils._.extend({}, Utils._.cloneDeep(options) || {}, {
// no limit, offset, order, attributes or include for the options given to count()
offset : 0,
limit : 0,
order : null,
include : null,
attributes: []
})
// no limit, offset, order, attributes or include for the options given to count()
, copts = Utils._.omit(options || {}, ['offset', 'limit', 'order', 'include', 'attributes'])
return new Utils.CustomEventEmitter(function (emitter) {
var emit = {
......@@ -378,20 +371,21 @@ module.exports = (function() {
, sql : function(s) { // emit SQL
emitter.emit('sql', s);
}
}
}
self.count(copts)
.on('sql', emit.sql)
.error(emit.err)
.success(function(cnt) {
if (cnt === 0)
if (cnt === 0) {
return emit.okay(cnt) // no records, no need for another query
}
self.findAll(options)
.on('sql', emit.sql)
.error(emit.err)
.success(function(rows) {
emit.okay(cnt, rows)
emit.okay(cnt, rows)
})
})
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!