Good afternoon, today a small question has arisen. 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 wanted was for example to send the object params without some keys, not to update to undefined but to preserve what is already there. I have already seen that it is possible to dynamically generate the query but what I wanted was to know if there is any way in the query to do that.