-
-
Save danneu/3a3075aa2ed41b4941e852abbe089e59 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.getMovieFromId = function(id) { | |
return table_movies.select('*').where({ movie_id: id }).first().then((movie) => | |
if (movie) return movie | |
return movies.insert(...).returning('*') // returns promise that resolves as the inserted movie | |
}); | |
}; | |
exports.getMovies = function() { | |
return Promise.all([ | |
exports.getMovieFromId(1), | |
exports.getMovieFromId(2), | |
exports.getMovieFromId(3), | |
exports.getMovieFromId(4), | |
exports.getMovieFromId(5), | |
]) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment