import { Article } from '@prisma/client' import { ApiProperty } from '@nestjs/swagger' import { UserEntity } from 'src/users/entities/user.entity' export class ArticleEntity implements Article { @ApiProperty() id: number @ApiProperty() title: string @ApiProperty({ required: false, nullable: true }) description: string | null @ApiProperty() body: string @ApiProperty() published: boolean @ApiProperty() createdAt: Date @ApiProperty() updatedAt: Date @ApiProperty({ required: false, nullable: true }) authorId: number | null; @ApiProperty({ required: false, type: UserEntity }) author?: UserEntity constructor({ author, ...data }: Partial) { Object.assign(this, data) if (author) { this.author = new UserEntity(author) } } }