Guest User

Untitled

a guest
Apr 23rd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. CREATE OR REPLACE FUNCTION get_users_by_ids(_uids text[])
  2. RETURNS JSON AS
  3. $func$
  4. SELECT json_agg(sub)
  5. FROM (
  6. SELECT u.id, u.username
  7. , ARRAY (SELECT followid FROM followers WHERE userid = u.id) AS following
  8. , ARRAY (SELECT userid FROM followers WHERE followid = u.id) AS followers
  9. FROM users u
  10. WHERE u.id = ANY (_uids)
  11. ) sub
  12. $func$ LANGUAGE sql SECURITY DEFINER;
Add Comment
Please, Sign In to add comment