Hey, I've been trying to insert few details into ...
# javascript
q
Hey, I've been trying to insert few details into supabase, but it gives me an error stating "invalid type for uuid" can anyone let me know what am I missing (edit) : removed the error message, since it contained some personal infomation
s
What is
user
in the instance of your insert method? also you don't need to pass an array if you are only inserting one record.
q
user is the current user from
supabase.auth.user()
I've tried to remove '[' , but I get the same error
Object { hint: null, message: "invalid input syntax for type uuid: \"{\"id\":\"102be471-e935-472a-9da1-96fab6fcd34d\",\"aud\":\"authenticated\",\"role\":\"authenticated\",\"email\":\"XXX@gmail.com\",\"email_confirmed_at\":\"2021-09-11T15:06:18.39005Z\",\"phone\":\"\",\"confirmation_sent_at\":\"2021-09-11T12:28:08.997287Z\",\"confirmed_at\":\"2021-09-11T15:06:18.39005Z\",\"recovery_sent_at\":\"2021-09-12T19:18:23.425893Z\",\"email_change_confirm_status\":0,\"last_sign_in_at\":\"2021-09-12T19:18:36.52333Z\",\"app_metadata\":{\"provider\":\"email\"},\"user_metadata\":{},\"created_at\":\"2021-09-11T12:28:08.988717Z\",\"updated_at\":\"2021-09-11T12:28:08.988717Z\"}\"", code: "22P02", details: null }
s
The issue is this, you are passing an entire object to a
uuid
field
Copy code
js
const user = supabase.auth.user();
// this is what you need => user.id
so in your insert
user_id: user.id
is what it should be
q
it works!! thanks 😄