Skip to content

Instantly share code, notes, and snippets.

@bursteways
Created May 12, 2025 15:46
Show Gist options
  • Select an option

  • Save bursteways/db3bf4a8b0cf00a7c234b4e2b5e6c453 to your computer and use it in GitHub Desktop.

Select an option

Save bursteways/db3bf4a8b0cf00a7c234b4e2b5e6c453 to your computer and use it in GitHub Desktop.
Prisma createMany type helper
import { PrismaClient } from '@prisma/client';
type PrismaModelName = keyof PrismaClient;
// Get the Prisma delegate type for a given model name
type GetDelegate<Model extends PrismaModelName> = NonNullable<
PrismaClient[Model]
>;
// Extract the `createMany` input `data` type for a model
export type InferCreateManyInput<Model extends PrismaModelName> =
GetDelegate<Model> extends { createMany: (...args: infer Args) => any }
? Args[0] extends { data: infer D }
? D
: never
: never;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment