{"id":13847297,"url":"https://github.com/vegardit/prisma-generator-nestjs-dto","last_synced_at":"2025-09-17T07:31:23.695Z","repository":{"id":37072447,"uuid":"377191934","full_name":"vegardit/prisma-generator-nestjs-dto","owner":"vegardit","description":"Generates NestJS DTO classes from Prisma Schema","archived":true,"fork":false,"pushed_at":"2024-06-26T19:43:30.000Z","size":1198,"stargazers_count":294,"open_issues_count":26,"forks_count":87,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-09-04T12:58:11.464Z","etag":null,"topics":["maintainer-wanted","nestjs","openapi","prisma-schema","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vegardit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-15T14:29:17.000Z","updated_at":"2025-09-04T12:00:30.000Z","dependencies_parsed_at":"2024-01-15T20:49:14.032Z","dependency_job_id":"6ac35e08-4b66-4d25-9419-ef2e0150e133","html_url":"https://github.com/vegardit/prisma-generator-nestjs-dto","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/vegardit/prisma-generator-nestjs-dto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fprisma-generator-nestjs-dto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fprisma-generator-nestjs-dto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fprisma-generator-nestjs-dto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fprisma-generator-nestjs-dto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vegardit","download_url":"https://codeload.github.com/vegardit/prisma-generator-nestjs-dto/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fprisma-generator-nestjs-dto/sbom","scorecard":{"id":918042,"data":{"date":"2025-08-11","repo":{"name":"github.com/vegardit/prisma-generator-nestjs-dto","commit":"181cbc415dfd97f1070b153970e3175b22138faa"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/1 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"project is archived","details":["Warn: Repository is archived."],"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/vegardit/prisma-generator-nestjs-dto/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/vegardit/prisma-generator-nestjs-dto/main.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of   1 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 29 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"28 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-pgw7-wx7w-2w33","Warn: Project is vulnerable to: GHSA-3cvr-822r-rqcc","Warn: Project is vulnerable to: GHSA-q768-x9m6-m9qp","Warn: Project is vulnerable to: GHSA-8qr4-xgw6-wmr3","Warn: Project is vulnerable to: GHSA-f772-66g8-q5h3","Warn: Project is vulnerable to: GHSA-5r9g-qh6m-jxff","Warn: Project is vulnerable to: GHSA-r6ch-mqf9-qc9w","Warn: Project is vulnerable to: GHSA-wqq4-5wpv-mx2g","Warn: Project is vulnerable to: GHSA-3787-6prv-h9w3","Warn: Project is vulnerable to: GHSA-9qxr-qj54-h672","Warn: Project is vulnerable to: GHSA-m4v8-wqvr-p9f7","Warn: Project is vulnerable to: GHSA-c76h-2ccp-4975","Warn: Project is vulnerable to: GHSA-cxrh-j4jr-qwg3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T22:16:44.285Z","repository_id":37072447,"created_at":"2025-08-24T22:16:44.285Z","updated_at":"2025-08-24T22:16:44.285Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275037885,"owners_count":25394636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["maintainer-wanted","nestjs","openapi","prisma-schema","typescript"],"created_at":"2024-08-04T18:01:15.971Z","updated_at":"2025-09-17T07:31:23.347Z","avatar_url":"https://github.com/vegardit.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Project Status: Looking for new maintainers!\n\nThis project is looking for maintainers.\n\nWe are not using this package anymore ourselves, so we can no longer validate/review/test any incoming PRs anymore and ensure correct functionality.\n\nIf you are an experienced open source contributor and are interested in taking over maintenance, please open a GitHub issue and let's discuss how to proceed.\n\n\n# Prisma Generator NestJS DTO\n\n[![Release](https://badge.fury.io/js/%40vegardit%2Fprisma-generator-nestjs-dto.svg)](https://www.npmjs.com/package/@vegardit/prisma-generator-nestjs-dto)\n[![License](https://img.shields.io/github/license/vegardit/prisma-generator-nestjs-dto.svg?label=license)](#license)\n\n1. [What is it?](#what-is-it)\n1. [Usage](#usage)\n1. [Annotations](#annotations)\n1. [Example](#example)\n1. [Principles](#principles)\n1. [License](#license)\n\n## \u003ca name=\"what-is-it\"\u003e\u003c/a\u003eWhat is it?\n\nGenerates `ConnectDTO`, `CreateDTO`, `UpdateDTO`, and `Entity` classes for models in your Prisma Schema. This is useful if you want to leverage [OpenAPI](https://docs.nestjs.com/openapi/introduction) in your [NestJS](https://nestjs.com/) application - but also helps with GraphQL resources as well). NestJS Swagger requires input parameters in [controllers to be described through classes](https://docs.nestjs.com/openapi/types-and-parameters) because it leverages TypeScript's emitted metadata and `Reflection` to generate models/components for the OpenAPI spec. It does the same for response models/components on your controller methods.\n\nThese classes can also be used with the built-in [ValidationPipe](https://docs.nestjs.com/techniques/validation#using-the-built-in-validationpipe) and [Serialization](https://docs.nestjs.com/techniques/serialization).\n\n## \u003ca name=\"usage\"\u003e\u003c/a\u003eUsage?\n\n```sh\nnpm install --save-dev @vegardit/prisma-generator-nestjs-dto\n```\n\n```prisma\ngenerator nestjsDto {\n  provider                        = \"prisma-generator-nestjs-dto\"\n  output                          = \"../src/generated/nestjs-dto\"\n  outputToNestJsResourceStructure = \"false\"\n  exportRelationModifierClasses   = \"true\"\n  reExport                        = \"false\"\n  createDtoPrefix                 = \"Create\"\n  updateDtoPrefix                 = \"Update\"\n  dtoSuffix                       = \"Dto\"\n  entityPrefix                    = \"\"\n  entitySuffix                    = \"\"\n  fileNamingStyle                 = \"camel\"\n}\n```\n\n### Parameters\n\nAll parameters are optional.\n\n- [`output`]: (default: `\"../src/generated/nestjs-dto\"`) - output path relative to your `schema.prisma` file\n- [`outputToNestJsResourceStructure`]: (default: `\"false\"`) - writes `dto`s and `entities` to subfolders aligned with [NestJS CRUD generator](https://docs.nestjs.com/recipes/crud-generator). Resource module name is derived from lower-cased model name in `schema.prisma`\n- [`exportRelationModifierClasses`]: (default: `\"true\"`) - Should extra classes generated for relationship field operations on DTOs be exported?\n- [`reExport`]: (default: `false`) - Should an index.ts be created for every folder?\n- [`createDtoPrefix`]: (default: `\"Create\"`) - phrase to prefix every `CreateDTO` class with\n- [`updateDtoPrefix`]: (default: `\"Update\"`) - phrase to prefix every `UpdateDTO` class with\n- [`dtoSuffix`]: (default: `\"Dto\"`) - phrase to suffix every `CreateDTO` and `UpdateDTO` class with\n- [`entityPrefix`]: (default: `\"\"`) - phrase to prefix every `Entity` class with\n- [`entitySuffix`]: (default: `\"\"`) - phrase to suffix every `Entity` class with\n- [`fileNamingStyle`]: (default: `\"camel\"`) - how to name generated files. Valid choices are `\"camel\"`, `\"pascal\"`, `\"kebab\"` and `\"snake\"`.\n\n## \u003ca name=\"annotations\"\u003e\u003c/a\u003eAnnotations\n\nAnnotations provide additional information to help this generator understand your intentions. They are applied as [tripple slash comments](https://www.prisma.io/docs/concepts/components/prisma-schema#comments) to a field node in your Prisma Schema. You can apply multiple annotations to the same field.\n\n```prisma\nmodel Post {\n  /// @DtoCreateOptional\n  /// @DtoUpdateHidden\n  createdAt   DateTime @default(now())\n}\n```\n\n- @DtoReadOnly - omits field in `CreateDTO` and `UpdateDTO`\n- @DtoEntityHidden - omits field in `Entity`\n- @DtoCreateOptional - adds field **optionally** to `CreateDTO` - useful for fields that would otherwise be omitted (e.g. `@id`, `@updatedAt`)\n- @DtoUpdateOptional- adds field **optionally** to `UpdateDTO` - useful for fields that would otherwise be omitted (e.g. `@id`, `@updatedAt`)\n- @DtoRelationRequired - marks relation **required** in `Entity` although it's optional in PrismaSchema - useful when you don't want (SQL) `ON DELETE CASCADE` behavior - but your logical data schema sees this relation as required\n  (**Note**: becomes obsolete once [referentialActions](https://github.com/prisma/prisma/issues/7816) are released and stable)\n- @DtoRelationCanCreateOnCreate - adds [create](https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#create-a-related-record) option on a relation field in the generated `CreateDTO` - useful when you want to allow to create related model instances\n- @DtoRelationCanConnectOnCreate - adds [connect](https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#connect-an-existing-record) option on a relation field in the generated `CreateDTO` - useful when you want/need to connect to an existing related instance\n- @DtoRelationCanCreateOnUpdate - adds [create](https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#create-a-related-record) option on a relation field in the generated `UpdateDTO` - useful when you want to allow to create related model instances\n- @DtoRelationCanConnectOnUpdate - adds [connect](https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#connect-an-existing-record) option on a relation field in the generated `UpdateDTO` - useful when you want/need to connect to an existing related instance\n\n## \u003ca name=\"example\"\u003e\u003c/a\u003eExample\n\n\u003cdetails\u003e\n  \u003csummary\u003ePrisma Schema\u003c/summary\u003e\n\n  ```prisma\n\ngenerator nestjsDto {\nprovider = \"prisma-generator-nestjs-dto\"\noutput = \"../src\"\noutputToNestJsResourceStructure = \"true\"\n}\n\nmodel Question {\nid String @id @default(dbgenerated(\"gen_random_uuid()\")) @db.Uuid\n/// @DtoReadOnly\ncreatedAt DateTime @default(now())\n/// @DtoRelationRequired\ncreatedBy User? @relation(\"CreatedQuestions\", fields: [createdById], references: [id])\ncreatedById String? @db.Uuid\nupdatedAt DateTime @updatedAt\n/// @DtoRelationRequired\nupdatedBy User? @relation(\"UpdatedQuestions\", fields: [updatedById], references: [id])\nupdatedById String? @db.Uuid\n\n    /// @DtoRelationRequired\n    /// @DtoRelationCanConnectOnCreate\n    category   Category? @relation(fields: [categoryId], references: [id])\n    categoryId String?   @db.Uuid\n\n    /// @DtoCreateOptional\n    /// @DtoRelationCanCreateOnCreate\n    /// @DtoRelationCanConnectOnCreate\n    /// @DtoRelationCanCreateOnUpdate\n    /// @DtoRelationCanConnectOnUpdate\n    tags Tag[]\n\n    title     String\n    content   String\n    responses Response[]\n\n}\n\n````\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eGenerated results\u003c/summary\u003e\n\n```ts\n// src/question/dto/connect-question.dto.ts\nexport class ConnectQuestionDto {\n  id: string;\n}\n````\n\n```ts\n// src/question/dto/create-question.dto.ts\nimport { ApiExtraModels } from '@nestjs/swagger';\nimport { ConnectCategoryDto } from '../../category/dto/connect-category.dto';\nimport { CreateTagDto } from '../../tag/dto/create-tag.dto';\nimport { ConnectTagDto } from '../../tag/dto/connect-tag.dto';\n\nexport class CreateQuestionCategoryRelationInputDto {\n  connect: ConnectCategoryDto;\n}\nexport class CreateQuestionTagsRelationInputDto {\n  create?: CreateTagDto[];\n  connect?: ConnectTagDto[];\n}\n\n@ApiExtraModels(\n  ConnectCategoryDto,\n  CreateQuestionCategoryRelationInputDto,\n  CreateTagDto,\n  ConnectTagDto,\n  CreateQuestionTagsRelationInputDto,\n)\nexport class CreateQuestionDto {\n  category: CreateQuestionCategoryRelationInputDto;\n  tags?: CreateQuestionTagsRelationInputDto;\n  title: string;\n  content: string;\n}\n```\n\n```ts\n// src/question/dto/update-question.dto.ts\nimport { ApiExtraModels } from '@nestjs/swagger';\nimport { CreateTagDto } from '../../tag/dto/create-tag.dto';\nimport { ConnectTagDto } from '../../tag/dto/connect-tag.dto';\n\nexport class UpdateQuestionTagsRelationInputDto {\n  create?: CreateTagDto[];\n  connect?: ConnectTagDto[];\n}\n\n@ApiExtraModels(CreateTagDto, ConnectTagDto, UpdateQuestionTagsRelationInputDto)\nexport class UpdateQuestionDto {\n  tags?: UpdateQuestionTagsRelationInputDto;\n  title?: string;\n  content?: string;\n}\n```\n\n```ts\n// src/question/entities/question.entity.ts\nimport { User } from '../../user/entities/user.entity';\nimport { Category } from '../../category/entities/category.entity';\nimport { Tag } from '../../tag/entities/tag.entity';\nimport { Response } from '../../response/entities/response.entity';\n\nexport class Question {\n  id: string;\n  createdAt: Date;\n  createdBy?: User;\n  createdById: string;\n  updatedAt: Date;\n  updatedBy?: User;\n  updatedById: string;\n  category?: Category;\n  categoryId: string;\n  tags?: Tag[];\n  title: string;\n  content: string;\n  responses?: Response[];\n}\n```\n\n\u003c/details\u003e\n\n## \u003ca name=\"principles\"\u003e\u003c/a\u003ePrinciples\n\nGenerally we read field properties from the `DMMF.Field` information provided by `@prisma/generator-helper`. Since a few scenarios don't become quite clear from that, we also check for additional [annotations](#annotations) (or `decorators`) in a field's `documentation` (that is anything provided as a [tripple slash comments](https://www.prisma.io/docs/concepts/components/prisma-schema#comments) for that field in your `prisma.schema`).\n\nInitially, we wanted `DTO` classes to `implement Prisma.\u003cModelName\u003e\u003c(Create|Update)\u003eInput` but that turned out to conflict with **required** relation fields.\n\n### ConnectDTO\n\nThis kind of DTO represents the structure of input-data to expect from 'outside' (e.g. REST API consumer) when attempting to `connect` to a model through a relation field.\n\nA `Model`s `ConnectDTO` class is composed from a unique'd list of `isId` and `isUnique` scalar fields. If the `ConnectDTO` class has exactly one property, the property is marked as required. If there are more than one properties, all properties are optional (since setting a single one of them is already sufficient for a unique query) - you must however specify at least one property.\n\n`ConnectDTO`s are used for relation fields in `CreateDTO`s and `UpdateDTO`s.\n\n### CreateDTO\n\nThis kind of DTO represents the structure of input-data to expect from 'outside' (e.g. REST API consumer) when attempting to `create` a new instance of a `Model`.\nTypically the requirements for database schema differ from what we want to allow users to do.\nAs an example (and this is the opinion represented in this generator), we don't think that relation scalar fields should be exposed to users for `create`, `update`, or `delete` activities (btw. TypeScript types generated in PrismaClient exclude these fields as well). If however, your schema defines a required relation, creating an entity of that Model would become quite difficult without the relation data.\nIn some cases you can derive information regarding related instances from context (e.g. HTTP path on the rest endpoint `/api/post/:postid/comment` to create a `Comment` with relation to a `Post`). For all other cases, we have the\n\n- `@DtoRelationCanCreateOnCreate`\n- `@DtoRelationCanConnectOnCreate`\n- `@DtoRelationCanCreateOnUpdate`\n- `@DtoRelationCanConnectOnUpdate`\n\n[annotations](#annotations) that generate corresponding input properties on `CreateDTO` and `UpdateDTO` (optional or required - depending on the nature of the relation).\n\nWhen generating a `Model`s `CreateDTO` class, field that meet any of the following conditions are omitted (**order matters**):\n\n- `isReadOnly` OR is annotated with `@DtoReadOnly` (_Note:_ this apparently includes relation scalar fields)\n- field represents a relation (`field.kind === 'object'`) and is not annotated with `@DtoRelationCanCreateOnCreate` or `@DtoRelationCanConnectOnCreate`\n- field is a [relation scalar](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/#annotated-relation-fields-and-relation-scalar-fields)\n- field is not annotated with `@DtoCreateOptional` AND\n  - `isId \u0026\u0026 hasDefaultValue` (id fields are not supposed to be provided by the user)\n  - `isUpdatedAt` ([Prisma](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#updatedat) will inject value)\n  - `isRequired \u0026\u0026 hasDefaultValue` (for schema-required fields that fallback to a default value when empty. Think: `createdAt` timestamps with `@default(now())` (see [now()](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#now)))\n\n### UpdateDTO\n\nWhen generating a `Model`s `UpdateDTO` class, field that meet any of the following conditions are omitted (**order matters**):\n\n- field is annotated with `@DtoUpdateOptional`\n- `isReadOnly` OR is annotated with `@DtoReadOnly` (_Note:_ this apparently includes relation scalar fields)\n- `isId` (id fields are not supposed to be updated by the user)\n- field represents a relation (`field.kind === 'object'`) and is not annotated with `@DtoRelationCanCreateOnUpdate` or `@DtoRelationCanConnectOnUpdate`\n- field is a [relation scalar](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/#annotated-relation-fields-and-relation-scalar-fields)\n- field is not annotated with `@DtoUpdateOptional` AND\n  - `isId` (id fields are not supposed to be updated by the user)\n  - `isUpdatedAt` ([Prisma](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#updatedat) will inject value)\n  - `isRequired \u0026\u0026 hasDefaultValue` (for schema-required fields that fallback to a default value when empty. Think: `createdAt` timestamps with `@default(now())` (see [now()](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#now)))\n\n### Entity\n\nWhen generating a `Model`s `Entity` class, only fields annotated with `@DtoEntityHidden` are omitted.\nAll other fields are only manipulated regarding their `isRequired` and `isNullable` flags.\n\nBy default, every scalar field in an entity is `required` meaning it doesn't get the TypeScript \"optional member flag\" `?` next to it's name. Fields that are marked as optional in PrismaSchema are treated as `nullable` - meaning their TypeScript type is a union of `field.type` and `null` (e.g. `string | null`).\n\nRelation and [relation scalar](https://www.prisma.io/docs/concepts/components/prisma-schema/relations/#annotated-relation-fields-and-relation-scalar-fields) fields are treated differently. If you don't specifically `include` a relation in your query, those fields will not exist in the response.\n\n- every relation field is always optional (`isRequired = false`)\n- relations are nullable except when\n  - the relation field is a one-to-many or many-to-many (i.e. list) type (would return empty array if no related records found)\n  - the relation was originally flagged as required (`isRequired = true`)\n  - the relation field is annotated with `@DtoRelationRequired` (do this when you mark a relation as optional in PrismaSchema because you don't want (SQL) `ON DELETE CASCADE` behavior - but your logical data schema sees this relation as required)\n\n## \u003ca name=\"license\"\u003e\u003c/a\u003eLicense\n\nAll files are released under the [Apache License 2.0](https://github.com/vegardit/prisma-generator-nestjs-dto/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvegardit%2Fprisma-generator-nestjs-dto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvegardit%2Fprisma-generator-nestjs-dto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvegardit%2Fprisma-generator-nestjs-dto/lists"}