Skip to content

Duplication between prisma schema and modelsΒ #427

@Skona27

Description

@Skona27

Hi!
First of all thanks for this starter. It is really awesome πŸ˜ƒ

I've noticed that some of the code is duplicated between prisma schema definitions and nest js models.
In prisma.schema we have a User definition, which looks like below:

model User {
  id        String   @id @default(cuid())
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  email     String   @unique
  password  String
  firstname String?
  lastname  String?
  posts     Post[]
  role      Role
}

And also in user.model we define the same 'shape' but with typescript:

@ObjectType()
export class User extends BaseModel {
  email: string;
  firstname?: string;
  lastname?: string;
  role: Role;
  @HideField()
  password: string;
}

Why is that necessary? Can't we somehow generate schema from models, or other way around?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions