guarantee ordering when using leveldb back end

startup might be a little bit slower now
but we shouldn't see "too much recursion" errors
closes #6 (in theory)
pull/1/head
ansuz 9 years ago
parent c2eb29b75e
commit 9b56cbbaca

@ -59,13 +59,19 @@ module.exports.create = function(conf,cb){
getMessages: function(cName, cb){ getMessages: function(cName, cb){
/* get all messages relating to a channel */ /* get all messages relating to a channel */
getIndex(cName, function(index){ getIndex(cName, function(index){
for(var i=index;i>=0;i--){ var last = index,
db.get(cName+'=>'+i,function(e,out){ i = 0,
next = function () {
db.get(cName+'=>'+i, function (e,out) {
if(e) return console.error(e); if(e) return console.error(e);
cb(out); cb(out);
}); if (++i <= last) {
next();
} }
}); });
};
next();
});
}, },
}); });
}; };

Loading…
Cancel
Save