Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(crud-response-interceptor): classToPlain call two times #526

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

strelov1
Copy link

#525

@Transform in DTO called two times, this occurring only with alwaysPaginate set true

@Transform((value, obj) => obj.F2 + ':' + obj.F2)

DATA:
{ "F1":1, "F2":"YaEvwfvzVi" }

Server response:
{ "data":[ { "F1":1, "F2":"YaEvwfvzVi:1:1" } ], "count":1, "total":1000, "page":1, "pageCount":1000 }

test_controller.ts

@Crud({
  model: {
    type: TestDataDto
  },
  query: {
    alwaysPaginate: true,
  }
})
@Controller('test')
export class TestController implements CrudController<TestData>{
  constructor(public service: TestService){}
}

test_service.ts

@Injectable()
export class TestService extends TypeOrmCrudService<TestData>{
  constructor(@InjectRepository(TestData) usersRepository: Repository<TestData>){
    super(usersRepository);
  }
}

test_entity.ts

@Entity({ name: 'TEST_DATA' })
export class TestData {
  @PrimaryColumn()
  public F1: number;

  @Column()
  public F2: string;
}

test_dto.ts

@Exclude()
export class TestDataDto {
  @Expose()
  public F1: string;

  @Expose()
  @Transform((value, obj) => obj.F2 + ':' + obj.F1)
  public F2: string;
}

@AliYusuf95
Copy link

This is a possible fix for #438

@rewiko rewiko mentioned this pull request Nov 28, 2021
19 tasks
@rewiko
Copy link
Collaborator

rewiko commented Nov 28, 2021

I am trying to help and have forked this repo (can't reach the owner of this repo and do not have the credential for the npm repo).

See #710 (comment)

We can hopefully merge it via rewiko#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants