Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION get_users_by_ids(_uids text[])
- RETURNS JSON AS
- $func$
- SELECT json_agg(sub)
- FROM (
- SELECT u.id, u.username
- , ARRAY (SELECT followid FROM followers WHERE userid = u.id) AS following
- , ARRAY (SELECT userid FROM followers WHERE followid = u.id) AS followers
- FROM users u
- WHERE u.id = ANY (_uids)
- ) sub
- $func$ LANGUAGE sql SECURITY DEFINER;
Add Comment
Please, Sign In to add comment