help on how to structure schema

lets say on a basic todo example, if we want an user specific todo, what id do I use to add it to the todo? do I need the user id or the account id, or the id in account table? or there is a better way to make private data to specific users? Im using drizzle, should I use a foreign key or something to reference on the table?
2 Replies
sebastian
sebastian3mo ago
Yeah, you reference user id. Then you can get the id from the session and query your database based on that. In drizzle it looks like this:
userId: text('user_id').references(() => user.id, { onDelete: 'cascade' }),
userId: text('user_id').references(() => user.id, { onDelete: 'cascade' }),
varo
varoOP3mo ago
thanks!

Did you find this page helpful?