omar-dulaimi / prisma-zod-generator

Prisma 2+ generator to emit Zod schemas from your Prisma schema
MIT License
535 stars 45 forks source link

<ModelName>CreateManySchema, data expects object and not array. #50

Closed feelixe closed 1 year ago

feelixe commented 1 year ago

Bug description

When creating schemas for a model ("MyModel") the MyModelCreateManySchema schema will have a data property that points to the schema MyModelCreateManyInputObjectSchema.

MyModelCreateManyInputObjectSchema is defined to be an object with the model fields and not an array of objects.

As the name implies I'm expecting this to be the input that corresponds to the prisma model.createMany input. But they do not match since the zod-schema does not accept array of objects.

How to reproduce

  1. Create any Prisma model.
  2. Generate schemas.
  3. Look in generated/schemas/createMany<modelname>.schema.ts and generated/schemas/objects/<modelname>CreateManyInput.schema

Expected behavior

<modelname>CreateManyInputObjectSchema should be a schema for an array of objects of type

Prisma information

Not specific for my schema will be same for any.

Environment & setup

Prisma Version

4.7.0