Skip to content

Instantly share code, notes, and snippets.

@myndzi
Created December 11, 2016 22:34
Show Gist options
  • Save myndzi/4b986ec64c21d0cb8ab3756283b008ae to your computer and use it in GitHub Desktop.
Save myndzi/4b986ec64c21d0cb8ab3756283b008ae to your computer and use it in GitHub Desktop.
var qb = knex.select('songs.id', 'songs.name AS song', 'artists.name AS artist', 'songs.path', 'albums.name AS album')
.from('songs')
.join('genreAssociation', 'songs.id', 'genreAssociation.id_songs')
.join('artists', 'songs.id_artists', 'artists.id')
.join('albums', 'songs.id_albums', 'albums.id')
.where('genreAssociation.id', req.params.id)
if (req.session.playedSongs && req.session.playedSongs.length != 0 && req.session.playedSongs != []) {
qb.whereNotIn('songs.id', req.session.playedSongs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment