Cheqo
05/15/2023, 2:47 PMJohnny Robert
05/15/2023, 2:55 PMhttps://cdn.discordapp.com/attachments/1107682620004909146/1107682620218814594/Screenshot_at_May_15_17-52-30.png▾
Philipp_Nut
05/15/2023, 3:45 PMjoshuabaker
05/15/2023, 4:47 PMven
05/15/2023, 5:19 PMhttps://cdn.discordapp.com/attachments/1107718871512785058/1107718871949004961/supabase_local_instance.png▾
https://cdn.discordapp.com/attachments/1107718871512785058/1107718872536195162/supabase_remote_instance.png▾
dave
05/15/2023, 5:54 PMSupabaseClient
instance (TypeScript), can I get the email address without needing to do a fetch?
getUser
causes a GET request, which I want to avoid.mohonish
05/15/2023, 6:24 PMgeorgeg3g3g3
05/15/2023, 6:34 PMDannyDanDan
05/15/2023, 7:55 PMhttps://cdn.discordapp.com/attachments/1107758122514256035/1107758122682036354/image.png▾
formigueiro
05/15/2023, 8:49 PMjs
const logout = async () => {
await supabase.auth.signOut()
router.push('/login')
}
https://cdn.discordapp.com/attachments/1107771875960045570/1107771876446576690/image.png▾
user8923
05/15/2023, 9:41 PMjson
{"email":"user@example.com","data":{},"create_user":true,"gotrue_meta_security":{},"code_challenge":null,"code_challenge_method":null}
Response:
json
{
"code": 500,
"msg": "Database error finding user",
"error_id": "d8899365-2eea-46ce-a1ec-561724b7e743"
}
Is I hit my GUI button one more time to trigger signInWithOtp() again, it works, the user gets created in the DB and everything is dandy.
Please note that this is using a local development Supabase environment as provided by supabase-cli.
I have not been able to test on my remote servers yet.
I'm not sure where to start troubleshooting this. I think gotrue runs in the Kong container. The logs tab for Kong in Docker Desktop has nothing worthwhile, just the HTTP log.zerosodium
05/15/2023, 10:55 PMjs
const { data, error } = await supabase.auth.signInWithOAuth({
provider: "google",
});
is there a user key value pair in addition to data and error? ts is complaining it doesn't existAlanK
05/15/2023, 11:16 PMimagio
05/15/2023, 11:42 PMActual Left Shark
05/16/2023, 12:11 AMprofiles
table to show things like "posts", "username" etc... but having trouble with the logic.
I have the following code in my <Navbar />
and looks like this
"use client"
import { useState, useEffect } from "react";
import { useSupabase } from './supabase-provider'
export default function Navbar () {
const { supabase } = useSupabase()
const [user,setUser] = useState(null)
const [profileData, setprofileData] = useState(null)
useEffect(() => {
supabase.auth.onAuthStateChange(async (event, session) => {
setUser(session?.user ?? null); <<<--- this works for setting the user state and things
if(session.user){ <<<<----- issue here
fetchData()
}
});
async function fetchData() { <<<------- issue here as well
const { data } = await supabase.from('profile').select('*').match({ id: user.id})
setprofileData(data)
}
}, [supabase.auth,supabase]);
console.log("user data", profileData)
console.log("user info log", user)
const signIn = () => {
supabase.auth.signInWithPassword({
email: "email@email.com",
password: "password123",
})
}
const signOut = () => {
supabase.auth.signOut()
// setUser('')
}
return (
<div>
<button className="m-3" onClick={signIn}>Sign In</button>
<button className="m-3" onClick={signUp}>Sign Up</button>
<button className="m-3" onClick={signOut}>Sign Out</button>
{/* This is what I am struggling with */}
{user ? <p>Welcome {user.email}</p> : <><p>No One here</p></>}
</div>
)
};
any help would be great!formigueiro
05/16/2023, 1:05 AMsql
create table
public.url_data (
id uuid not null default gen_random_uuid (),
slug text null,
long_url character varying(255) null,
total_clicks bigint null,
created_at timestamp without time zone not null default now(),
updated_at timestamp without time zone not null default now(),
user_id uuid null,
constraint url_data_pkey primary key (id),
constraint url_data_shortened_key unique (long_url),
constraint url_data_slug_key unique (slug),
constraint url_data_user_id_fkey foreign key (user_id) references auth.users (id) on delete cascade
) tablespace pg_default;
clicks sql
create table
public.clicks (
id bigint generated by default as identity not null,
created_at timestamp with time zone null default now(),
ip character varying null,
country character varying null,
city character varying null,
user_agent text null,
url_id uuid null,
constraint clicks_pkey primary key (id),
constraint clicks_url_id_fkey foreign key (url_id) references url_data (id)
) tablespace pg_default;
create trigger increment_total_clicks_trigger
after insert on clicks for each row
execute function increment_total_clicks_on_url_data ();
and im creating a function to trigger when click is inserted sql
begin
update public.url_data
set total_clicks = total_clicks + 1
where id = new.url_id;
return new;
end
but its not updating total_clicks from url_dataNegative
05/16/2023, 2:04 AMesque
05/16/2023, 3:04 AMJohnny008
05/16/2023, 6:06 AMZyrano
05/16/2023, 7:15 AMMATTI
05/16/2023, 9:13 AMFezVrasta
05/16/2023, 9:41 AMservices.user_id
column is set with a foreign key relation to users.id
.
In Supabase studio I see the relation working, if I click the right arrow next to a user_id
it brings me to the correct user
entry.
I need to query a user and all its related services from Supabase JS now, and I'm using:
js
const { data, error } = await supabase
.from('users')
.select('*, services(*)')
.eq('id', id)
.single();
The problem is that this returns me the correct user object, but with an empty array as `services`:
{ id: 0, name: 'Foobar', services: [] }
These are my table definitions:
sql
create table
public.services (
id uuid not null,
created_at timestamp with time zone null default now(),
constraint users_id_pkey primary key (id)
) tablespace pg_default;
create table
public.services (
id uuid not null,
user_id uuid not null,
created_at timestamp with time zone not null default now(),
name text not null,
constraint services_pkey primary key (id),
constraint services_user_id_fkey foreign key (user_id) references users (id) on delete cascade
) tablespace pg_default;
What am I doing wrong? I have data in the database that should be returned.andy.nguyen
05/16/2023, 9:45 AMPaul AKA TDI
05/16/2023, 10:01 AMKBar
05/16/2023, 10:48 AM/metadata
endpoint even exist?Tairosonloa
05/16/2023, 10:52 AMbenemanu
05/16/2023, 11:51 AMenti
05/16/2023, 12:22 PMbombillazo
05/16/2023, 12:24 PMdev
.
Both devs pull the branch, and run supabase start
locally to do their development on a local db. They each make independent changes to the database locally and generate a migration file (using supabase db diff
) called m_A
and m_B
respectively.
Dev A's changes are reviewed, merged and deployed to remote successfully in branch dev
.
Now, what is the best way for dev B to pull those migration changes (m_A
) into his local dev environment without losing his own development changes (m_B
)? I'm sure dev B would need to recreate the migration file but they should do so based on the newest deployed state.jacobart
05/16/2023, 1:13 PM