cleaner plugin: optimize getMessages

This commit is contained in:
Manuel Araoz 2014-09-01 17:33:46 -03:00
parent 349972a047
commit fe682c173f

View File

@ -97,10 +97,10 @@ MessageDb.prototype.getMessages = function(to, lower_ts, upper_ts, cb) {
var list = [];
lower_ts = lower_ts || 1;
var opts = {
end: messageKey(to, lower_ts),
start: messageKey(to, upper_ts),
start: messageKey(to, lower_ts),
end: messageKey(to, upper_ts),
// limit: limit, TODO
reverse: true,
reverse: false,
};
db.createReadStream(opts)
@ -112,12 +112,13 @@ MessageDb.prototype.getMessages = function(to, lower_ts, upper_ts, cb) {
return cb(err);
})
.on('end', function() {
return cb(null, list.reverse());
return cb(null, list);
});
};
MessageDb.prototype.remove = function(ts) {
MessageDb.prototype.removeUpTo = function(ts) {
var opts = {};
db.createKeyStream(opts);
};
module.exports = soop(MessageDb);