Created
April 16, 2012 14:01
-
-
Save dannyamey/2399018 to your computer and use it in GitHub Desktop.
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.index = function(req, res, next) { | |
client.sort('movies', 'BY', 'movie:*:data->year', 'LIMIT', '0', '12', 'ALPHA', 'DESC', 'GET', '#', function(err, replies) { | |
var movies = []; | |
async.forEachSeries(replies, function(reply, done) { | |
client.hgetall('movie:'+reply+':data', function(err, movie) { | |
if (err) return done(err); | |
movies.push(movie); | |
done(); | |
}); | |
}, function(err) { | |
if (err) return next(err); | |
client.sort('genres', 'BY', 'genre:*:name', 'ALPHA', 'ASC', 'GET', '#', function(err, genre_ids) { | |
var genres = []; | |
async.forEachSeries(genre_ids, function(genre_id, done) { | |
client.get('genre:'+genre_id+':name', function(err, val) { | |
if (err) return done(err); | |
genres.push({ id: genre_id, name: val }) | |
done(); | |
}); | |
}, function(err) { | |
res.render('index', { | |
movies: JSON.stringify(movies) | |
genres: genres | |
}); | |
}); | |
}); | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment