"feat: Added debug server and related components for improved development experience"
This commit is contained in:
29
frontend/src/utils/drizzle.ts
Normal file
29
frontend/src/utils/drizzle.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type * as schema from "@/server/db/schema";
|
||||
import type { BuildQueryResult, DBQueryConfig, ExtractTablesWithRelations } from "drizzle-orm";
|
||||
|
||||
type Schema = typeof schema;
|
||||
type TSchema = ExtractTablesWithRelations<Schema>;
|
||||
|
||||
/**
|
||||
* Infer the relation type of a table.
|
||||
*/
|
||||
export type IncludeRelation<TableName extends keyof TSchema> = 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<TableName> | undefined = undefined,
|
||||
> = BuildQueryResult<
|
||||
TSchema,
|
||||
TSchema[TableName],
|
||||
{
|
||||
with: With;
|
||||
}
|
||||
>;
|
Reference in New Issue
Block a user