import type * as schema from "@/server/db/schema"; import type { BuildQueryResult, DBQueryConfig, ExtractTablesWithRelations } from "drizzle-orm"; type Schema = typeof schema; type TSchema = ExtractTablesWithRelations; /** * Infer the relation type of a table. */ export type IncludeRelation = DBQueryConfig< "one" | "many", boolean, TSchema, TSchema[TableName] >["with"]; /** * Infer the result type of a query with optional relations. */ export type InferResultType< TableName extends keyof TSchema, With extends IncludeRelation | undefined = undefined, > = BuildQueryResult< TSchema, TSchema[TableName], { with: With; } >;