I am make a nodejs project with postgresql as the backend and i use pg_promise as the driver for queries
curretly i have to do a select statement with columns that may vary but are all having the same equality condition check, like below
pg.any('select * from table where col1 = ${col1} and col2 = ${col2}',{
col1:value1,
col2:value2
});
// which generates the query shown below
// select * from table where col2 = value1 and col2 = value2;
what i want is to hopefully find a easier way to generate the select query with variable no of columns having equality where conditions, something similiar to what pg_promise allows us to user helpers.update to genearte update queries.
// something like shown below
pg.helpers.select('select * from table ',{col1:value1, col2:value2})
// it shoud generate the same as the query with static columns
//select * from table where col2 = value1 and col2 = value2;