How to add to the database where the table has a many relationship to another table
I have a users table, which has a many relationship to to a posts table.
I want to add a new user to the table, which I can do, but how do I go about adding new posts to that user? Does it add a full post object to the user? Or just an id to the new post which will be in the post table?
I want to add a new user to the table, which I can do, but how do I go about adding new posts to that user? Does it add a full post object to the user? Or just an id to the new post which will be in the post table?
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom().unique().notNull(),
username: varchar('username', { length: 512 }).unique().notNull(),
});
export const usersRelations = relations(users, ({ many }) => ({
posts: many(posts),
}));