Hello, i have some json data (let say { "name": "B...
# javascript
l
Hello, i have some json data (let say { "name": "Bob", "age": "30" }, { "name": "Ema", "age": "30" }, etc) and i would like to insert it into my database. I dont know how to map through the data to insert it automatically. Thanks
b
If you create a JSONB column in your table, it's very easy to insert JSON data into it.
If you're using the Supabase JavaScript client, just insert it. As in:
Copy code
supabase.from('table')
.insert({"my_json_field":{"name":"Bob","age":30}});
pretty straightforward
if using straight SQL, like in the query editor, you just put it in quotes:
insert into table (my_json_field) values ('{"my_json_field":{"name":"Bob","age":30}');
l
The problem is i want to chose what property to insert.
Let says i just want to import the "name" and not the "age"
b
With JSON fields you can put whatever you want into the field. It doesn't matter.
l
Ok i will look into it thanks for advice