My use case is pretty simple. I need to increment ...
# help
a
My use case is pretty simple. I need to increment a column from a group of users whose IDs I pass as an array.
g
You pretty much can search the internet for postgresql functions and describe what you want and probably get close. I have a simple function using an array input:
Copy code
create function get_by_ids(ids bigint[]) returns SETOF messages
    language plpgsql
as
$$
begin
    return query
      select * from messages where id in (ids);
    end;
$$;
You could pass in json and get the ids from that, just have to ask in sql thread or google plpgsql array from json or some such. I don't know the syntax without searching for it.
a
Thank you. I was thinking of that approach. I'm looking for it.
I couldn't find a proper way to extract array from json yet :/ I'm very new to the SQL and postgresql world.
g
SELECT json_array_elements('[1,true, [2,false]]'); https://www.w3resource.com/PostgreSQL/postgresql-json-functions-and-operators.php hopefully that gets you going