-
I think this is where I am stuck with Hasura... Need your assistance please. I am trying to create the below function but you can see that I am passing the comments as a parameters but I also am doing a self inner join on the comments table... Create or replace FUNCTION users_with_top_comments(comments_row comments) I am getting the error
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Answering my own question. I was having "as users" in the first select which was conflicting and secondly, the column in the comments_row needed to be quoted within ".." Create or replace FUNCTION users_with_top_comments(comments_row comments) CREATE OR REPLACE FUNCTION public.users_with_top_comments(comments_row comments) |
Beta Was this translation helpful? Give feedback.
Answering my own question.
I was having "as users" in the first select which was conflicting and secondly, the column in the comments_row needed to be quoted within ".."
Create or replace FUNCTION users_with_top_comments(comments_row comments)
RETURNS SETOF users AS $$
select distinct(users.id) as id, users.username, users."firebaseId",count("comments".id) as plusOneRankMain,
---> users."plusOneRankComments", users."profilePicture", users."createdOn" from users as users
inner join "public"."comments" as com on com."userId" = users.id
---> where users.id = comments_row.userId
group by users.id
$$ LANGUAGE sql STABLE;
CREATE OR REPLACE FUNCTION public.users_with_top_comments(comments_row co…