Patryk Makowski
09/23/2022, 10:45 AMbhark
09/23/2022, 12:07 PMauth.uid() in (
select profile_id from team_members
where team_id = node.team_id
)
But it throws this error: missing FROM-clause entry for table "node"
Where am I going wrong?Amr
09/23/2022, 12:54 PMstops
sql
- id - name
|- 1 - Cairo
|- 2 - Giza
and another table trips
sql
- id - departure - arrival
|- 1 - 1 - 2
the departure
column is a foreign key to stops.id
and arrival
to the same stops.id
key.
Now I can't select from trips
while using left join
because of this error:
Failed to run sql query: table name "stops" specified more than once
Of course I tried this first in SQL editor in supabase, but I'll use the js client for the project.omar
09/23/2022, 1:17 PMInspectorT
09/23/2022, 1:18 PMtrack
call, I often get back "rate limited" as the response, even after having not called track
after several seconds. It sometimes seems to stay in that state so I can never call track
successfully again unless I reload the page.
I tried digging through the realtime client code, and it seems like there is a way to configure eventsPerSecond
but it's unclear to me how that's related and how to configure it on the channel. Any guidance would be a great help, thanks!psteinroe
09/23/2022, 1:58 PMMrGandalfAndhi
09/23/2022, 2:02 PMHunterAndersonX
09/23/2022, 2:46 PMXzight
09/23/2022, 3:02 PMPOST
a new task that has tags? To do this I will need to insert on the Tasks table and TagsToTasks table. I am hoping to avoid a situation where client first makes a POST
request to Tasks and then to TagsToTasks after since then I would probably need to have a transaction to handle rollback. Is this something I should use an edge function for?stevharve
09/23/2022, 3:46 PMjsx
useEffect(() => {
const subscription = supabase
.channel('public:messages')
.on(
'postgres_changes',
{
event: 'INSERT',
schema: 'public',
table: 'messages',
// filter: 'team_id.eq.' + teamId,
},
async (payload: any) => {
onInsert && onInsert();
}
)
.subscribe((status: string) => {
console.log('status', status);
status === 'SUBSCRIBED' && onConnection && onConnection();
});
return () => {
subscription.unsubscribe();
};
}, [teamId]);
Anoushk
09/23/2022, 4:14 PMCory
09/23/2022, 4:18 PMgantiplex
09/23/2022, 5:59 PMHunterAndersonX
09/23/2022, 6:29 PMAdam Ambrosius
09/23/2022, 6:48 PMSUPABASE_URL
and SUPABASE_ANON_KEY
and those are populated successfully. I only have one project, I have linked it and am running supabase start
, supabase functions serve function-name
.
Here is the only code that is being executed which is modeled directly off of the examples provided.
js
import { createClient } from "https://esm.sh/@supabase/supabase-js@^1.33.2";
export const supabaseClient = createClient(
// Supabase API URL - env var exported by default when deployed.
Deno.env.get("SUPABASE_URL") ?? "",
// Supabase API ANON KEY - env var exported by default when deployed.
Deno.env.get("SUPABASE_ANON_KEY") ?? ""
);
js
import { serve } from "https://deno.land/std@0.131.0/http/server.ts";
import { supabaseClient } from "../_shared/supabaseClient.ts";
serve(async (req) => {
console.log(Deno.env.get("SUPABASE_URL") ?? "");
console.log(Deno.env.get("SUPABASE_ANON_KEY") ?? "");
const { data, error } = await supabaseClient.from("positions").select("*");
console.log({ data, error });
return new Response(JSON.stringify(data), {
headers: { "Content-Type": "application/json" },
});
});
What do I need to do so that I can execute this locally?ven
09/23/2022, 7:16 PMlouisstephensca
09/23/2022, 8:15 PM((()))
09/23/2022, 9:28 PMpre
offices
└ id
└ name
employees
└ id
└ office_id
└ name
office_id in employees table is linked to offices.id.
When I query employees right now, I get something like
json
[
{
"user_id": "0dea707d-2248-4a2e-b8fd-b65578852ca9",
"office_id": 1,
"name": "Karen"
}
]
QUESTION:
is it possible to replace that office_id with office name so I get something like this when I query select * from employees
json
[
{
"user_id": "0dea707d-2248-4a2e-b8fd-b65578852ca9",
"office": "Billing Department",
"name": "Karen"
}
]
tyakymiuk
09/23/2022, 9:32 PMauth
object inside postgres function that's being called via RPC just like we're accessing auth.uid()
in e.g. RLS policies. If the answer is yes, it's possible
maybe you also know a way how to access it using plv8
language for writing those functions? Maybe there's a reserved word for it
As a side question: are there any drawbacks in using .rpc() instead of .select() all the way through? (Just like endpoints and perform all the validations, checks, etc. there)HunterAndersonX
09/23/2022, 9:50 PMsob
09/23/2022, 10:57 PMrgfx
09/23/2022, 11:56 PMMatt
09/24/2022, 1:41 AMjdgamble555
09/24/2022, 5:33 AMtypescript
supabase start
supabase gen types typescript --local > DatabaseDefinitions.ts
But of course it thinks I am running a local Docker version of Supabase. How can I generate the types from my cloud database?
Thanks,
JXzight
09/24/2022, 5:47 AMsql
create or replace function getTasksWithTags(input_owner_id uuid) returns table(id int8, title text, description text, priority text, due_by timestamptz, is_completed bool, tag_ids int8, tag_titles text) as $$
begin
return query select tasks.id, tasks.title, tasks.description, tasks.priority, tasks.due_by, tasks.is_completed, tags_to_tasks.tag_id, tags.title from tasks
left join tags_to_tasks on tasks.id = tags_to_tasks.task_id
left join tags on tags_to_tasks.tag_id = tags.id
where tasks.owner_id = input_owner_id;
end;
$$ language plpgsql;
What I am wondering is instead of having a row for each tag
that is on a task
how can I make the output 1 row per task with an array for tag_ids
and tag_titles
Oenu
09/24/2022, 8:57 AMshmarts
09/24/2022, 9:33 AMkingpeppe
09/24/2022, 10:20 AMCANDY
09/24/2022, 10:39 AMAnoushk
09/24/2022, 11:53 AM