#How to map Dynamodb Data return with DTO?

1 messages · Page 1 of 1 (latest)

halcyon cradle
#

Here I have

import {
IsString,
IsInt,
IsUUID,
IsEnum,
IsDateString,
IsOptional,
} from 'class-validator';

export class JobsDto {
@IsString()
@IsUUID()
id: string;

@IsString()
@IsEnum(['languageLine', 'cli', 'plunet'])
entity_type: string;

@IsString()
@IsDateString()
created_at: string;

@IsString()
created_by: string;

@IsString()
@IsDateString()
updated_at: string;

@IsString()
updated_by: string;

@IsString()
@IsEnum([
'created',
'validated',
'validation-failed',
'processed',
'cancelled',
])
status: string;

@IsString()
@IsEnum(['ui', 'api'])
mode: string;

@IsString()
file_location: string;

@IsOptional()
@IsInt()
number_of_records: number;

@IsOptional()
@IsString()
log_file_location: string;

@IsOptional()
@IsString()
detailed_status: string;

@IsOptional()
offset: object;
}

Like there may be some fields in not available but when I'm return few fields it complaints

#

is there any way or other way??

#

So what I'm doing here is when new Job is created JobsCreateDto is return and if get request for job i'm returing JobsDto. which is repeatable code I want to use only on Object is I can resuse for multiple response.

`export class JobsDto {
@IsString()
@IsUUID()
id: string;

@IsString()
@IsEnum(['languageLine', 'cli', 'plunet'])
entity_type: string;

@IsString()
@IsDateString()
created_at: string;

@IsString()
created_by: string;

@IsString()
@IsDateString()
updated_at: string;

@IsString()
updated_by: string;

@IsString()
@IsEnum([
'created',
'validated',
'validation-failed',
'processed',
'cancelled',
])
status: string;

@IsString()
@IsEnum(['ui', 'api'])
mode: string;

@IsString()
file_location: string;

@IsOptional()
@IsInt()
number_of_records: number;

@IsOptional()
@IsString()
log_file_location: string;

@IsOptional()
@IsString()
detailed_status: string;
}`

`export class JobsCreateDto {
@IsString()
@IsEnum(['languageLine', 'cli', 'plunet'])
entity_type: string;

@IsString()
@IsEnum(['ui', 'api'])
mode: string;

@IsString()
file_location: string;

@IsString()
@IsDateString()
created_at: string;

@IsString()
created_by: string;

@IsString()
@IsDateString()
updated_at: string;

@IsString()
updated_by: string;
}`

#

is there any way to do this thing like?

high dewBOT
#

Please do not tag the moderators unless someone is breaking server rules. The mods are here to help enforce the rules of the server, and while most of them are knowledgeable about Nest, they are not the only ones able to solve your question.

halcyon cradle
#

@shy star Could you please help me or advise ?

shy star
halcyon cradle
#

Yes I got it

#

sorry It was my mistake

shy star
#

Obviously not because you still pinged me right after you were told not to ping the mods

halcyon cradle
#

Sorry I was not aware

quasi junco
halcyon cradle
#

You are right

#

I need some time to digest information

#

I will go through the documentation