Skip to content

Instantly share code, notes, and snippets.

@KrisKnez
Created February 24, 2024 18:49
Show Gist options
  • Save KrisKnez/bdda0a828fd2988f270f1e9771e3c0a7 to your computer and use it in GitHub Desktop.
Save KrisKnez/bdda0a828fd2988f270f1e9771e3c0a7 to your computer and use it in GitHub Desktop.
Order By Dto For Notes
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