0
Good afternoon, today I had a little doubt. Somewhere in my code I have a query to do an update. The function is as follows:
function updateUser(user_id, params) {
const query = `UPDATE users
SET user_name = $1,
user_brithday = $2,
user_active = $3
WHERE user_id = $4`;
const queryParams = [
params.user_name,
params.user_brithday,
params.user_ative,
user_id
];
return pg.query(query, queryParams);
}
What I intended was for example to send Object params without some keys, not to update to Undefined but to preserve what is already there. I have seen that it is possible to generate the query dynamically but what I wanted to know is if there is any way in the query to do this.