how do I store list of string in my pg table

I want to store a list of user ids in my table with currently I am doing this editors:text("editors").array().references(() => users.id, { onDelete: "cascade",}), which is giving me this error error: foreign key constraint "youtube_channel_editors_user_id_fk" cannot be implemented Detailed error => detail: 'Key columns "editors" and "id" are of incompatible types: text[] and text.', where: 'SQL statement "ALTER TABLE "youtube_channel" ADD CONSTRAINT "youtube_channel_editors_user_id_fk" FOREIGN KEY ("editors") REFERENCES "user"("id") ON DELETE cascade ON UPDATE no action"\n' + 'PL/pgSQL function inline_code_block line 2 at SQL statement'
3 Replies
Angelelz
Angelelz11mo ago
I'm not sure you can have an array column as a foreign key Why not a one-to-many relation?
Izaan
Izaan11mo ago
@Angelelz It seemd cool so
Angelelz
Angelelz11mo ago
Lol Having arrays in databases are useful for contrive examples IMO. Like tags that you don't need to index or so
Want results from more Discord servers?
Add your server