-
Notifications
You must be signed in to change notification settings - Fork 46
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers
Description
Is your feature request related to a problem? Please describe.
It seems obvious that the createdAt
, updatedAt
, and __v
fields are not used anywhere on the front end. so we can remove them from API responses.
Describe the solution you'd like
- Add an
Exclude
decorator to an entity, like,
import { Exclude } from 'class-transformer';
export class MyEntity {
...
@Exclude()
createdAt: Date;
@Exclude()
updatedAt: Date;
@Exclude()
__v?: number;
}
- Add
__v
in the SchemaDocument,
interface IMyDocument extends MyEntity, Document {
_id: never;
__v: never;
}
- In the controller apply the
ClassSerializerInterceptor
interceptor, like,
import { Body, ClassSerializerInterceptor, UseInterceptors } from '@nestjs/common';
...
@UseInterceptors(ClassSerializerInterceptor)
export class MyController {
...
}
- Build
dal
lib by runningpnpm build:dal
. - Test respective API is sending the correct response.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomers