DevThoughts
10/10/2022, 8:08 PMthasmo
10/10/2022, 9:20 PMsupabase-js
is not the right choice but using something like https://www.npmjs.com/package/pg-pool does the job?
I need to connect and read data from within a serverless function; and I'd like to get the response as quick as possible. As far as I understand, supabase-js
is "just" a client for the REST API.kvnfo
10/10/2022, 10:07 PM{events.user_id === user?.id && (
<div className="flex">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="w-4 h-4 cursor-pointer hover:opacity-80"
onClick={() => setIsOpen((prev) => !prev)}
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="M10.5 6h9.75M10.5 6a1.5 1.5 0 11-3 0m3 0a1.5 1.5 0 10-3 0M3.75 6H7.5m3 12h9.75m-9.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-3.75 0H7.5m9-6h3.75m-3.75 0a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m-9.75 0h9.75"
/>
</svg>
</div>
)}
rlee128
10/10/2022, 10:13 PMjoshcowan25
10/10/2022, 10:26 PMTom3
10/11/2022, 1:10 AMtrack()
and add to the state for security reasons.
Does anyone have any suggestions? Thanks.DC
10/11/2022, 3:28 AMrunejeppesen
10/11/2022, 6:24 AMin
10/11/2022, 9:40 AMcreate function public.handle_new_user()
returns trigger as
$$
begin
-- if new.email_confirmed_at is not null then
insert into public.users (...)
values (...);
return new;
-- end if;
end;
$$
language plpgsql security definer;
create trigger on_auth_user_created
after insert on auth.users
for each row
execute procedure public.handle_new_user();
If you keep the condition commented out, the row will be inserted every time, even if just invited by email.
If you add the condition, user invitation/creation doesn't work anymore and gives the following error:
Failed to invite user: failed to make invite request: Database error saving new user
The code is valid, but there is something in the "create user" function from the auth schema that is bothered by that condition.
Btw, I wanted to have a look at that function in pgAdmin but all my Supabase servers were disconnected, impossible to reconnect (all my other non-Supabase servers work just fine). Is there currently a problem that is still not reported on status.supabase.com?drewbie
10/11/2022, 1:54 PMuseReactQuery
does take a generic which will be the return type of the fetched data. However, I'm a bit lost on what that return type should be as a lot of it looks like its inferred from the table name in the standalone v2 client.
typescript
type GeneratedQuery = PostgrestFilterBuilder<any, any> & { _table?: string };
type QueryCreator = (supabase: SupabaseClient<Database>) => PostgrestFilterBuilder<any, any> & { _table?: string };
function useQuery(queryCreator: QueryCreator, options?: UseQueryOptions & { queryKey?: string | unknown[] }) {
const query = queryCreator(client);
const execute = (query: GeneratedQuery) =>
new Promise<any>(async (resolve, reject) => {
const { data, error } = await query;
if (data) {
resolve(data);
} else {
reject(error);
}
});
return useReactQuery(options?.queryKey ?? [query._table], () => execute(query), options);
}
When I call useQuery
in a component (eg) Id like the return type of the client query to go to categories
typescript
const categories = useQuery((supabase) => supabase.from("categories" *this table name autocompleted fine).select("name, id"));
categories.{no types on the return value of categories :/}
This has sort of stretched my knowledge of Typescript thin and any help is appreciated!Lukas V
10/11/2022, 1:58 PMSolemensis
10/11/2022, 3:24 PMconst { data, error } = await supabase
.from('myrow')
.insert([
{ id: 11, desc: 'heyrow' },
])
But it inserts only on page re-loads of course. When i try to wrap it in a async function;
async function insert() {
const { data, error } = await supabase
.from('myrow')
.insert([
{ id: 11, desc: 'heyrow' },
])
}
and put it on a click event; (vue/nuxt3)
<button @click="insert()">click</button>
Row insert is not working with click event. What am i doing wrong?Iwan
10/11/2022, 4:22 PMJames Perkins
10/11/2022, 5:43 PMsupabase.auth.setAuth(token)
and deleted all of the documentation that now just gives you a
> Page Not Found
> We could not find what you were looking for.
>
> Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
>
It is impossible to find what the alternative of this is. So I am wondering if someone can help me.Abnormal
10/11/2022, 5:44 PMVengeance
10/11/2022, 5:50 PMtime_bucket
I get Failed to run sql query: function time_bucket(unknown, timestamp with time zone) does not exist
, any ideas?
https://docs.timescale.com/api/latest/hyperfunctions/time_bucketDJPaul
10/11/2022, 6:05 PMlewisd
10/11/2022, 6:27 PMsendConfirmEmail()
function (or something similarly named)
The email im after is sent automatically when a user signs up which is great, but my migrated users are technically already signed up, so I need to send a confirmation email manually.
One idea 💡: If I send a magic link/OTP and they sign in with that, does that also confirm the email? I suppose that could do if so.Theodore
10/12/2022, 4:30 AMSacha
10/11/2022, 7:41 PMccssmnn
10/11/2022, 8:16 PMsupabase.from("posts").select("*, labels(*)")
I receive all posts and all of their labels. Now, when I want to see posts with label 1
, the query will look like this: supabase.from("posts").select("*, labels!inner(*)").eq("labels.id", 1)
. But now I don't receive every label of each post anymore. I only get label 1
, since the other labels don't pass the filter.
Is there a way to get every post, that has label 1
while still receiving every other label?ledet
10/11/2022, 8:33 PMSolemensis
10/11/2022, 8:56 PMMrPreet
10/11/2022, 9:04 PMbengra
10/11/2022, 10:26 PMcbunge3
10/11/2022, 10:30 PMennio.exe
10/11/2022, 11:04 PM((()))
10/12/2022, 1:14 AMAnshuman
10/12/2022, 2:47 AMdb.from("workspaces").select().limit(1).eq("teamId", "<teamId>").single();
I found this in the API logs in Supabase dashboard
"search": "?select=*&teamId=eq.T034WB3JR27&limit=1&teamId=eq.T0431JUG2DB&teamId=eq.T0431JUG2DB&teamId=eq.T0431JUG2DB&teamId=eq.T0431JUG2DB&teamId=eq.T0431JUG2DB&teamId=eq.T0431JUG2DB",
}
I'm not sure why the` &teamId` query is repeated so much. The teamId are different.czypnt
10/12/2022, 2:50 AM