How should I store checkbox values in postgres

let say I have a checkbox list called interests and user checked some options. They will send request like this: interests: ['cars', 'hiking', 'dance'] and later on users will be able to change interests. lets say user unchecked hiking, new put request will be like this interests: ['cars', 'dance'] how should I store this data? seperate table?, simple array column? If I create seperate table, schema will be like this id: uuid userId: uuid reference user id interest: interest enum so when user send put request what should I do? delete all existing interests and insert new ones? is this normal way? sorry i am a sql noob
2 Replies
AuroPick
AuroPickOP10mo ago
Drizzle ORM - Filters
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
AuroPick
AuroPickOP10mo ago
what should I do if user add new value run two query? is there a way to do this in one query?
Want results from more Discord servers?
Add your server