https://supabase.com/ logo
#javascript
Title
# javascript
m

M1K3

10/21/2021, 8:15 PM
I'm having trouble inserting into a table
s

silentworks

10/21/2021, 8:16 PM
Please be more descriptive with your issue as this isn't very helpful for someone to be able to assist you
m

M1K3

10/21/2021, 8:16 PM
yeah sorry i was gonna type more lol
s

silentworks

10/21/2021, 8:16 PM
For future reference, type everything in one message before hitting enter
m

M1K3

10/21/2021, 8:17 PM
essentially im trying to take course data from an api and insert it into a supabase table. I don't get any errors in my code but nothing gets inserted into the table
s

silentworks

10/21/2021, 8:17 PM
btw I know how frustrating it can be when you hit a wall/error, but try to just take a little time and write out your thoughts before hitting enter.
m

M1K3

10/21/2021, 8:17 PM
no problem, will do next time
s

silentworks

10/21/2021, 8:18 PM
Can you provide an example of the code you are using? also do you have row level security (RLS) turned on on your table?
m

M1K3

10/21/2021, 8:18 PM
and yes I did enable row level security
s

silentworks

10/21/2021, 8:19 PM
If you are inserting a single entry you don't need the an array with an object, just pass the object to the insert function
m

M1K3

10/21/2021, 8:19 PM
ok
and btw for row level security all I did was enable it on this table in the GUI. I didn't write anything for it in the SQL query to make the table
s

silentworks

10/21/2021, 8:20 PM
Ah you will need to write a rule to allow insert then
That is what is causing the data from inserting
m

M1K3

10/21/2021, 8:20 PM
ahhh
What is the easiest way to do this?
s

silentworks

10/21/2021, 8:21 PM
It depends on what you want RLS for, is it to make sure only logged in users can add data?
m

M1K3

10/21/2021, 8:23 PM
I'll want users to be able to modify their "profile" at some point but right now my "course" table is just to take data from the API and insert all of it in. This table will be static after everything is inserted
s

silentworks

10/21/2021, 8:23 PM
Just turn off RLS for it then if you are using it now while in development
m

M1K3

10/21/2021, 8:23 PM
ok
I guess I'll worry about RLS later on then. Thanks!
s

silentworks

10/21/2021, 8:25 PM
Yeah if you are only inserting course data while in development, you can turn on RLS after and don't add a policy for INSERT but you will need to add one for SELECT.
m

M1K3

10/21/2021, 8:26 PM
gotcha... I'll definitely want any user to be able to SELECT data from the course table