Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
32 replies
elpupper

TRPC and PRISMA id type

Currently im trying to delete a object using id in prisma using trpc.

    delete: privateProcedure.input(
        z.object({
            id: z.string().cuid(),
        }),
    ).mutation(async ({ ctx, input }) => {
        const post = await ctx.prisma.teacher.delete({
            where: {
                id: input.id,
            },
        });
    }),


but im getting this error
❌ tRPC failed on teachers.delete: [
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "string",
    "path": [],
    "message": "Expected object, received string"
  }
]

Here is the schema

model Teacher {
    id        String   @id @default(cuid())
    createdAt DateTime @default(now())

    name      String
    email     String
    role      String
    phone     String
    dob       String

    authorId  String
}
Was this page helpful?