Skip to content

Does Prisma have a built-in generated type for picking only scalar fields from [Model]CreateInput? #24001

Closed Answered by ludralph
vietan0 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @vietan0 👋

Prisma does not provide a built-in type that includes only the non-relation scalar fields. However, you can create such a type yourself using TypeScript's utility types. For example, you can use the Omit utility type to remove the relation fields from the ProjectUncheckedCreateInput type:

 export type ProjectUncheckedCreateInput = {
    id?: string
    name: string
    body: string
    createdAt?: Date | string
    updatedAt?: Date | string
    userId: string
    tasks?: TaskUncheckedCreateNestedManyWithoutProjectInput
  }
type ProjectScalarInput = Omit<ProjectUncheckedCreateInput, 'userId' | 'tasks'>;

This will give you a type that includes only the non-relation scalar fiel…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by vietan0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants