Newb here, does anybody have experience with checking if a row exists in a db function?

Hi guys.

This is my current function (This function will basically increment a score between users):

create function increment_kudos (giver_id uuid, receiver_id uuid, amount int)
returns void as
$$
  update "userKudos"
  set kudos = kudos + amount
  where "giverId" = giver_id AND "receiverId" = receiver_id
$$
language sql volatile;


Problem is, the row needs to exist first if it is able to increment it.

Im quite new so im unsure of syntax regarding how to add this logic in sql. Does anyone have any tips?
Was this page helpful?