infer model with relations

is possible to infer model along with all its relations? Like if I have projects and projectsRelations which includes tasks can I create a type Project that includes tasks?
export const projects = mysqlTable(
"projects",
{
id: serial("id").primaryKey(),
name: varchar("name", { length: 256 }),
}
)

export const projectsRelations = relations(projects, ({ many }) => ({
tasks: many(tasks),
}))


export type Project = InferModel<<projects-with-its-relations>?>

// currently I just do
export type Project = InferModel<typeof projects> & {tasks?: Task[]}
export const projects = mysqlTable(
"projects",
{
id: serial("id").primaryKey(),
name: varchar("name", { length: 256 }),
}
)

export const projectsRelations = relations(projects, ({ many }) => ({
tasks: many(tasks),
}))


export type Project = InferModel<<projects-with-its-relations>?>

// currently I just do
export type Project = InferModel<typeof projects> & {tasks?: Task[]}
1 Reply
gerty1
gerty117mo ago
Same question here
Want results from more Discord servers?
Add your server