How can I select array of users and their related projects (many) as array?
Imagine I have these schemas:
How can I select all users, and their related projects?
How can I select all users, and their related projects?
// users table
export const users = pgTable("users", {
id: uuid("id").primaryKey().defaultRandom(),
name: text("name"),
});
// projects table
export const projects = pgTable("projects", {
id: uuid("id").primaryKey().defaultRandom(),
userId: uuid("user_id").references(() => users.id),
title: text("title"),
});