Created
September 14, 2012 06:41
-
-
Save sdepold/3720242 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var chainer = new Sequelize.Utils.QueryChainer() | |
Artist.find({ where: {name: name} }).success(function(artist) { | |
if (artist) { | |
// get all tracks | |
artist.getTracks().success(function (tracks) { | |
if (tracks.length > 0) { | |
tracks.forEach(function(track) { | |
chainer.add(track.getArtists()) | |
}) | |
chainer.run().success(function(artists) { | |
for(var i = 0; i < tracks.length; i++) { | |
tracks[i].artists = artists[i] | |
} | |
res.render('artist', { title: artist.name, artist: artist, tracks: tracks }); | |
}) | |
} else { | |
res.render('artist', { title: artist.name, artist: artist, tracks: tracks }); | |
} | |
}); | |
} else { | |
req.flash('error', 'Artist not found'); | |
res.redirect('/'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment