title: NestJS-Prisma, How to write a DTO that matches the prisma one to many type
body: <p>I'm new to NestJS and Prisma. I'm trying to write an API for the corresponding prisma model.</p>
  <p>Here is my prisma model:</p>
  <pre><code>    model orderable_test {
        id                 Int               @id @unique @default(autoincrement())
        test_name          String
        test_id            Int
        price              Int
        is_orderable       Boolean
        is_active          Boolean
        orderable_bundle   orderable_bundle? @relation(fields: [orderable_bundleId], references: [id])
        orderable_bundleId Int?
      }
      
      model orderable_bundle {
        id              Int              @id @unique @default(autoincrement())
        bundle_name     String
        bundle_id       Int
        price           Int
        is_orderable    Boolean
        is_active       Boolean
        orderable_tests orderable_test[]
      }
  </code></pre>
  <p>For the orderable_test, my DTO works well, the DTO for orderable_test is:</p>
  <pre><code>class OrderableTestDTO {
  
      @ApiProperty()
      test_name: string;
      @ApiProperty()
      test_id: number;
      @ApiProperty()
      price: number;
      @ApiProperty()
      is_orderable: boolean;
      @ApiProperty()
      is_active: boolean;
      @ApiPropertyOptional({default: null})
      orderable_bundleId:number|null;
  }
  </code></pre>
  <p>For the orderable_bundle DTO, I have</p>
  <pre><code>class OrderableBundleDTO {
      @ApiProperty()
      bundle_name: string;
      @ApiProperty()
      bundle_id: number;
      @ApiProperty()
      price: number;
      @ApiProperty()
      is_orderable: boolean;
      @ApiProperty()
      is_active: boolean;
      @ApiPropertyOptional({type: () =&gt; OrderableTestDTO})
      orderable_tests: OrderableTestDTO | null
  }
  </code></pre>
  <p>Based on the Prisma Official Document: I will need my DTO to be like</p>
  <pre><code>const createBundle = await prisma.bundle.create({
    data: {
      bundle_name: 'Bob',
      bundle_id: 1
      ............
      orderable_tests: {
        create: [
          {
            id: 'String',
            test_name: 'String',
            test_id: 1,
        price: 0
            .....
          },
        ],
      },
    },
  })
  </code></pre>
  <p>But currently, my DTO will be look like this: missing the <code>create:</code></p>
  <pre><code>const createBundle = await prisma.bundle.create({
    data: {
      bundle_name: 'Bob',
      bundle_id: 1
      ............
      orderable_tests: 
          {
            id: 'String',
            test_name: 'String',
            test_id: 1,
        price: 0
            .....
          },
  
      },
    },
  })
  </code></pre>
  <p>And for the auto generated Prisma type: It looks like:</p>
  <pre><code>  export type orderable_bundleCreateInput = {
      bundle_name: string
      bundle_id: number
      price: number
      is_orderable: boolean
      is_active: boolean
      orderable_tests?: orderable_testCreateNestedManyWithoutOrderable_bundleInput
    }
  
    export type orderable_testCreateNestedManyWithoutOrderable_bundleInput = {
      create?: XOR&lt;Enumerable&lt;orderable_testCreateWithoutOrderable_bundleInput&gt;, Enumerable&lt;orderable_testUncheckedCreateWithoutOrderable_bundleInput&gt;&gt;
      connectOrCreate?: Enumerable&lt;orderable_testCreateOrConnectWithoutOrderable_bundleInput&gt;
      createMany?: orderable_testCreateManyOrderable_bundleInputEnvelope
      connect?: Enumerable&lt;orderable_testWhereUniqueInput&gt;
    }
  </code></pre>
  <p>I'm really new into type script and prisma, is it possible to have a DTO that looks exactly to the auto genenated prisma type, if not, how can I add the create: before my inner orderable_test under the orderable_bundle DTO. Thanks for viewing my question!</p>