Created
January 17, 2013 16:30
-
-
Save atree/4557289 to your computer and use it in GitHub Desktop.
Node JS - Iterating over redis keys, grabbing value from hash for view.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.list = function(req, res) { | |
var return_dataset = []; | |
client.keys('*', function(err, log_list) { | |
var multi = client.multi(); | |
var keys = Object.keys(log_list); | |
var i = 0; | |
keys.forEach(function (l) { | |
client.hget(log_list[l], "modified_at", function(e, o) { | |
i++; | |
if (e) {console.log(e)} else { | |
temp_data = {'key':log_list[l], 'modified_at':o}; | |
return_dataset.push(temp_data); | |
} | |
if (i == keys.length) { | |
res.render('logger/list', {logs:return_dataset}); | |
} | |
}); | |
}); | |
}); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment