Hey would anybody be williing to hop in a vc for a...
# help
a
Hey would anybody be williing to hop in a vc for about 2 mins, I'm having some difficulty understanding how Supabase works and how I can send and receive data from it. I'm new to Web Dev so I will ask some dumb questions.
n
Hello @Aghilan! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
a
My question is regardling calling the API, I want to try testing it using Insomnia
But my request always goes through but returns nothing, even though data exists
d
I think that happens if I don't have the right headers
a
Currently I have Authentication is Supabase
How can I create a table so that each person has a Unique set of data, I dont know how to link a user to database. I know it has something to do with Foreign Key but I'm not sure how it works.
Ping me if you read this and are willing to help, I am at breaking point
@User Sorry for pinging you but I really require a bit of assistance I am going CRAZY.
o
you're looking for a getting started guide right?
a
Not really
I already read that
Im trying to set up a somwhat more complex DB with each User linking to another table where all their information is stored
I understand how to just use on table without relationships but I dont understand/know how to connect one DB to my users db
The docs tell me how to query a DB, that part isnt bad. I just cant figure out how to create and set it up to represent the data I want
d
You're trying to figure out how to model a SQL database correctly, right?
a
Yes
d
And so you have a user that's signed up, and they're in the auth.users table, right?
a
Yes
d
And now you want to add data to this user
Like a new column called name, and you want their name in there
a
Yes, I want to store Data specific to each User
Yea among other things
d
Do you have a table in the public schema? So public. ?
Maybe it's called users or something else?
a
What is public scheme?
d
When you sign up they go in the auth schema
It's in the table editor tab
a
Yes I have a scheme public
d
You can't access the auth schema via the client
So you need to make a table in public. And we can then link that public table to the auth.users table
a
How would I link them, would I have a ID row that has a foreign key from the users.id
d
Copy code
CREATE TABLE "public"."users" (
    "id" integer GENERATED ALWAYS AS IDENTITY,
    "user_id" text NOT NULL,
    "first_name" text NOT NULL,
    "likes_food" bool,
    PRIMARY KEY ("id"),
    FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE CASCADE
);
a
Sorry I got no clue what that means
I'm new to programming and even more new to Web Dev
d
Yeah. You might to look stuff up
Look up how to create a postgres table
What have you tried so far?
So what have you tried so far?
a
Ok so I think* my Users table is linked to my new table
d
You can run that query in supabase
a
Does that mean every user has their own DB?
d
Nope
a
Is there on DB where all USer Data is stored?
d
Rephrase?
a
So all my user data is stored in one database, and when I want to query it for just one user, I have to select on the user with a certain iD?
d
yup yup
a
Actually I cant even link my table to my auth.users table
I always get a error saying I cant type cast something
Would I link it to Instance ID or id?
d
What part of the query did I send you makes you confused?
FOREIGN KEY ("user_id") REFERENCES "auth"."users"("id") ON DELETE CASCADE
Give it a shot
a
?? Where would I write that
I barely know how to use the GUI
d
lmao
I told you where
Look up
a
Yea lol I have an hour to learn each day after im done school and work so I sincerely apologize for my noob questions
d
All good
a
Ok so should I dellete the current SQL queries and replace it with what you sent?
Do you think you would be able to call and I can screen share and you quickly explain to me how to link these tables and how to represent the data?
d
Nah
a
Lol
Ok I think I got it to work
What command would I use in Supabase/Js sot that I can select an entire row ONLY where a certain column of that row matches my result
@User
let { data } = await supabase.from("UserFinanceData").select("Investments");
I have a column in my UserFinanceData called UserID which is linked to my auth.users
Do Filters only work on Columns? I want only a Row where the data in the row matches what I gave it
SELECT * FROM UserFinanceData WHERE UserID = '{user.id}', how would I implement this
d
Have you read the Supabase quick start guide, looked at any documentation, or tried anything first?
a
Yes I did, I found a way around it. I think I misunderstood how the query selector works