How can i create a schema to the database?
Hi, how can i create a column which is an array of objects like
Thanks
10 Replies
In the dashboard table UI you just select text type and check array.
In SQL you just use text [] when creating the table or
ALTER TABLE candidate ADD COLUMN my_array_col text[]
So i can create it as text[] and i won't have any problems?
Maybe I'm missing what you want to do. Are you wanting an array of the whole thing you showed, or is that your table you are looking for? If the whole thing you showed is an object and you want an array of those, then you would be looking at json or jsonb array column
Yes, what i want is an array of that whole object
So this should do the work?

If you plan to search it then you probably should use jsonb.
I see
Thank you!
I'm not sure you even want an array column depending on what you are doing. A json/b column will take json including arrays inside the json.
https://hevodata.com/learn/query-jsonb-array-of-objects/
https://levelup.gitconnected.com/working-with-a-jsonb-array-of-objects-in-postgresql-d2b7e7f4db87
Kamya
Learn | Hevo
How to Query JSONB Array of Objects in PostgreSQL
Learn how to Query JSONB Array of Objects in PostgreSQL and perform CRUD operations like CREATE, INSERT, SELECT, UPDATE, DELETE on the objects.
Medium
Working with a JSONB Array of Objects in PostgreSQL
Get, Add and Remove JSON Objects from an Array
Thanks, i'll definatelly read it!