cleaner plugin: optimize getMessages
This commit is contained in:
parent
349972a047
commit
fe682c173f
@ -97,10 +97,10 @@ MessageDb.prototype.getMessages = function(to, lower_ts, upper_ts, cb) {
|
|||||||
var list = [];
|
var list = [];
|
||||||
lower_ts = lower_ts || 1;
|
lower_ts = lower_ts || 1;
|
||||||
var opts = {
|
var opts = {
|
||||||
end: messageKey(to, lower_ts),
|
start: messageKey(to, lower_ts),
|
||||||
start: messageKey(to, upper_ts),
|
end: messageKey(to, upper_ts),
|
||||||
// limit: limit, TODO
|
// limit: limit, TODO
|
||||||
reverse: true,
|
reverse: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
db.createReadStream(opts)
|
db.createReadStream(opts)
|
||||||
@ -112,12 +112,13 @@ MessageDb.prototype.getMessages = function(to, lower_ts, upper_ts, cb) {
|
|||||||
return cb(err);
|
return cb(err);
|
||||||
})
|
})
|
||||||
.on('end', function() {
|
.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);
|
module.exports = soop(MessageDb);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user