Skip to content

Instantly share code, notes, and snippets.

@dannyamey
Created April 16, 2012 15:22
Show Gist options
  • Save dannyamey/2399431 to your computer and use it in GitHub Desktop.
Save dannyamey/2399431 to your computer and use it in GitHub Desktop.
exports.genre = function(req, res, next) {
var genre_id = req.param('id'),
start = req.param('start', 0),
num = 12;
client.smembers('genre:'+genre_id+':movies', function(err, movie_ids){
var movies = [], end = start + num;
if (end > movie_ids.length) end = movie_ids.length;
movie_ids = movie_ids.slice(start, end);
async.forEachSeries(movie_ids, function(movie_id, done) {
client.hgetall('movie:'+movie_id+':data', function(err, movie) {
if (err) return done(err);
movies.push(movie);
done();
}, function(err) {
if (err) return next(err);
res.json(movies);
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment