make amnesiadb compatible with netflux

pull/1/head
ansuz 9 years ago
parent be1ef7abe3
commit e83e5026ce

@ -18,6 +18,7 @@ module.exports.create = function(conf, cb){
var db=[], var db=[],
index=0; index=0;
cb({ cb({
message: function(channelName, content, cb){ message: function(channelName, content, cb){
var val = { var val = {
@ -27,17 +28,18 @@ module.exports.create = function(conf, cb){
time: new Date().getTime(), time: new Date().getTime(),
}; };
db.push(val); db.push(val);
cb(); if (cb) { cb(); }
}, },
getMessages: function(channelName, cb){ getMessages: function(channelName, handler, cb){
db.sort(function(a,b){ db.sort(function(a,b){
return a.id - b.id; return a.id - b.id;
}); });
db.filter(function(val){ db.filter(function(val){
return val.chan === channelName; return val.chan === channelName;
}).forEach(function(doc){ }).forEach(function(doc){
cb(doc.msg); handler(doc.msg);
}); });
if (cb) { cb(); }
}, },
}); });
}; };

Loading…
Cancel
Save