I'm retrieving multiple fields of a redis hash key using HMGET to simply send them using JSON:
redis.HMGET('key', 'name', 'date', // a lot more fields here,
function(err, reply){
res.jsonp({
name: reply[0],
date: reply[1],
// other fields
});
}
);
Working with an high amount of fields is leading to a quite long list, and therefore for a less readable code. So I was wondering: is there a more beautiful and common way of mapping the reply array to the JSON response object - preferably without having to write down the field names twice?
null. HMGET is receiving the field names in seperate arguments, not as a single array (may have failed to make it really understanable). This approach would be a nice idea though!