Yumi
05/26/2023, 7:58 AMTheRien
05/26/2023, 8:19 AMVimes
05/26/2023, 9:21 AMRazoth
05/26/2023, 10:00 AMwonsky
05/26/2023, 10:35 AMhttps://cdn.discordapp.com/attachments/1111603430591582239/1111603430994219008/image.png▾
Daniel Klein
05/26/2023, 12:54 PMElofin
05/26/2023, 12:54 PMviktor
05/26/2023, 1:12 PMCREATE POLICY "logged in users can insert into myTable"
ON public.myTable FOR INSERT to authenticated
with check (
true
);
Error
new row violates row-level security policy for table "myTable
Postgres Username authenticator
Also is there an easy overview of all the different roles/ postgres usernames used, when they are used and for what? I fail too find one, would be nice with a cheatsheet.probo
05/26/2023, 1:20 PMprobo
05/26/2023, 1:26 PMVimes
05/26/2023, 1:41 PMType '{ [x: string]: any; }[]' is not assignable to type '{ contact_point: string....
I'm wondering how I can use these magical supabase types without TS saying "no sir"
js
type TaasTypes = Database["public"]["Tables"]["taas"]["Row"];
function TaaS({ tasks }: { tasks: TaasTypes[] }) { <- no error here
return (
<>
{tasks.map((task) => (
<div key={task.id}>
<h3>{task.task}</h3>
<p>{task.description}</p>
<p>Kontaktpunkt: {task.contact_point}</p>
</div>
))}
</>
);
}
const Kundeportal = async () => {
// Start supabase server client
const supabase = serverClient();
// Henter TaaS timer profilen kan se
const { data: taas, error: taasError } = await supabase
.from("taas")
.select(`*`);
return (<>
{taas ? <TaaS tasks={taas} /> : <p>Ingen TaaS-timer tilgjengelig</p>} <- ERORR is here
</>)
}
Tried something like this
js
const { data: taas , error: taasError } = await supabase
.from<TaasTypes>("taas")
.select(`*`);
adding <> behind types gives error
No overload expects 1 type arguments, but overloads do exist that expect either 0 or 2 type arguments.ts(2743)
imp
05/26/2023, 1:52 PMfrom supabase import create_client, Client
ModuleNotFoundError: No module named 'supabase'
Basically trying to import the supabase python library (I've tried pip install supabase
and pip install supabase-client`
already), but I keep getting this error. Does anyone have any suggestions or ideas on what could be wrong?PorkchopPanties
05/26/2023, 1:59 PMMartiN
05/26/2023, 2:24 PMmvmt
05/26/2023, 2:30 PMRichfella
05/26/2023, 3:17 PMSunTzu
05/26/2023, 3:17 PMSELECT * FROM messages m WHERE m.sources::text LIKE '%"document": 25%';
And works completely fine,
I'm trying to replicate this with the js library
const { data, error } = await supabase
.from("messages")
.select(`*`)
.like("sources", `%"document": ${id}%]`);
however unsure how I replicate the ``::text`` as like the SQL queryJames singh
05/26/2023, 3:30 PMjs
supabase.auth.onAuthStateChange(async (event) => {
if (!event) return;
if (event === 'SIGNED_IN') {
console.log('User signed in'); //this span in console multiple times
} else return
});
dmayo2
05/26/2023, 4:56 PMCREATE OR REPLACE FUNCTION update_grammar_count()
RETURNS TRIGGER AS $$
BEGIN
UPDATE grammar_count
SET total = total + NEW.char_count
WHERE id = 1;
INSERT INTO custom_logs (message)
VALUES('Trigger update_grammar_count fired');
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS grammar_count_insert_trigger ON grammar_stats;
CREATE TRIGGER grammar_count_insert_trigger
AFTER INSERT ON grammar_stats
FOR EACH ROW
EXECUTE FUNCTION update_grammar_count();
blakecross
05/26/2023, 5:33 PMxdcx18
05/26/2023, 5:39 PMsql
-- Drop the function if it exists
DROP FUNCTION IF EXISTS public.initialize_group();
-- Drop the trigger if it exists
DROP TRIGGER IF EXISTS initialize_group_trigger ON auth.users;
-- Create the function
CREATE FUNCTION public.initialize_group()
RETURNS TRIGGER
LANGUAGE plpgsql
SECURITY DEFINER
AS $$
BEGIN
NEW."groupId" := NEW.id;
RETURN NEW;
END;
$$;
-- Create the trigger
CREATE TRIGGER initialize_group_trigger
AFTER INSERT ON auth.users
FOR EACH ROW
EXECUTE FUNCTION public.initialize_group();
https://cdn.discordapp.com/attachments/1111710153620852787/1111710154535227534/Screenshot_2023-05-26_at_12.38.27_PM.png▾
matth
05/26/2023, 5:49 PMcreate or replace function migrate_contact_roles() returns setof test_contact_roles as $$
declare
d_roles text[] := array[]::text[];
d_id int;
d_acct boolean;
str_acct text = "acct";
begin
-- lookup 1 contact
select
id, is_acct into d_id, d_acct
from test_contact_roles where id = 1;
if (d_acct) then
d_roles := d_roles || str_acct;
end if;
update test_contact_roles set roles = d_roles where id = d_id;
return query select * from get_contacts()
where id = 1;
end;
$$ language plpgsql;
When I run the function I'm getting the following error
> Failed to run sql query: column "acct" does not exist
Any help or suggestions greatly appreciated! Thank you
https://cdn.discordapp.com/attachments/1111712651182092289/1111712651295326279/Screenshot_2023-05-26_at_12.38.16_PM.png▾
https://cdn.discordapp.com/attachments/1111712651182092289/1111712651567976549/Screenshot_2023-05-26_at_12.38.51_PM.png▾
James singh
05/26/2023, 6:42 PMjs
supabase.auth.onAuthStateChange(async (event) => {
if (!event) return;
if (event === 'SIGNED_IN') {
console.log('User signed in'); //this spam in console multiple times without load page
} else return
});
Cedric
05/26/2023, 7:03 PMosamita
05/26/2023, 7:10 PMsudoramen
05/26/2023, 7:44 PMts
import { serve } from "https://deno.land/std@0.168.0/http/server.ts"
import Stripe from "https://esm.sh/stripe@11.0.0?target=deno&no-check";
serve(async () => {
const stripe = Stripe(Deno.env.get('STRIPE_PROD_SECRET'), {
apiVersion: "2022-11-15",
httpClient: Stripe.createFetchHttpClient(),
})
return new Response(
JSON.stringify(await stripe.customers.list()),
{ headers: { "Content-Type": "application/json" } },
)
})
This runs just fine when serving locally but when deployed, I never get a response back. The env var does match so I know that's not the issue.cufta22
05/26/2023, 8:14 PMReactingMe
05/26/2023, 9:15 PMosamita
05/26/2023, 10:15 PMteekster
05/26/2023, 10:50 PM