max
04/26/2022, 8:38 AMcreate or replace function get_activities(radius int, point text)
returns setof activities as $$
var json_result = plv8.execute(
"SELECT activities.id, activities.name, activities.time, activities.participant_limit, row_to_json(activities_user.*) AS user FROM activities LEFT JOIN LATERAL ( SELECT users.full_name, users.avatar_url FROM users WHERE activities.added_by = users.id ) AS activities_user ON TRUE WHERE ST_DWithin(location, $1::geometry, $2) ORDER BY time asc", [point, radius]
);
return json_result;
$$ language plv8;
Running the query itself works fine, but when trying to run this function via supabase.rpc
I get a 500 with error code XX000 and message "field name / property name mismatch". I'm guessing that it is because my return type "activities" does not include the users table's field that I'm adding as part of the query. Any ideas how I can fix this?Needle
04/26/2022, 8:38 AM/title
command!
We have solved your problem?
Click the button below to archive it.Steve
05/01/2022, 6:35 AMNeedle
05/01/2022, 6:35 AMSteve
05/01/2022, 6:36 AMSteve
05/01/2022, 6:36 AM