Created
February 24, 2024 18:49
-
-
Save KrisKnez/bdda0a828fd2988f270f1e9771e3c0a7 to your computer and use it in GitHub Desktop.
Order By Dto For Notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApiProperty } from '@nestjs/swagger'; | |
import { IsEnum, IsOptional } from 'class-validator'; | |
import { Prisma } from '@prisma/client'; | |
const orderByKeys = [ | |
'id', | |
'title', | |
'content', | |
'createdAt', | |
'updatedAt', | |
'userId', | |
] as Array<keyof Prisma.NoteOrderByWithRelationInput>; | |
const orderByValues = Object.values(Prisma.SortOrder); | |
export class OrderByNoteDto { | |
@IsEnum(orderByKeys) | |
@IsOptional() | |
@ApiProperty({ | |
enum: orderByKeys, | |
}) | |
orderBy_key?: keyof Prisma.NoteOrderByWithRelationInput; | |
@IsEnum(orderByValues) | |
@IsOptional() | |
@ApiProperty({ | |
enum: orderByValues, | |
}) | |
orderBy_value?: Prisma.SortOrder; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment