I'm having some trouble with pg-promise.
I would like to specify an undefined number of parameters in the WHERE
clause.
All the parameters will be concatenated with OR
.
db.any(
'SELECT genre FROM genres'+
'WHERE ( (genres.genre LIKE \'Animation\' OR genres.genre LIKE \'Action\') ')
.then(function(data) {
// success;
})
.catch(function(error) {
// error;
});
});
Instead of specifying parameters one by one, I have an array of genres passed by the user.
I would like to do something like this...
var genres = ["Action", "Adventure", "Romantic"];
db.any(
'SELECT genre FROM genres'+
'WHERE ( (genres.genre LIKE $1) '), [genres])
.then(function(data) {
// success;
})
.catch(function(error) {
// error;
});
});
I can't find a way to make it work.
Thank you for your help!