I am working on a small project to learn Supabase and NextJS. I am trying to add a JSON object to my sites
array which is defined as a JSON array. I want to add the config (and more in the future) to the sites column based on the user's id that I get back from auth().
This is what I could come up with but I keep getting this error:
message: expected JSON array
. I've tried wrapping the object with brackets to create an array and that doesn't work either.
const { data, error } = await supabase
.from("users")
.insert({
sites: {...}) // config object
.eq("id", user?.id);
I've tried different Filters
per Supabase docs and nothing is working. There doesn't seem to be a clear way to update arrays with JSON from what I've searched, but I'm also very new to PostgreSQL databases.
json[]
. Make itjson
, then store an array value..insert({sites: {...})
to this =>.insert([sites: {...}])
?message: null value in column "id" of relation "users" violates not-null constraint
.insert({sites: {...}})
(or rather.insert({sites: [{...}]})
) is fine, but you should change the column type in the database.