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

Serialize the data array #80

Open
ppetzold opened this issue Sep 9, 2021 · 2 comments
Open

Serialize the data array #80

ppetzold opened this issue Sep 9, 2021 · 2 comments
Labels
enhancement New feature or request will accept PR

Comments

@ppetzold
Copy link
Owner

ppetzold commented Sep 9, 2021

Original: #72 (comment)

With serialization, I mean filtering and transforming the response data. Using class-transformer, for example.

For now, in my code, I have implemented an interceptor (also could be a class or helper function) to catch the Paginated and call the plainToClass() for data param. Here I can provide a small example for the better understanding:

// controller

const paginatedResults = await paginate(...) // Item[]
return {
    ...paginatedResults,
    data: plainToClass(ItemResponseDto, paginatedResults.data)
}
// ItemResponseDto with class-transformer

@Exclude()
export class ItemResponseDto {
  @Expose()
  id: string;
...
}

Having written this, I think this logic should be the responsibility of this module. So, nevermind 😅

@ppetzold ppetzold added will accept PR enhancement New feature or request labels Sep 9, 2021
@ricbermo
Copy link
Contributor

I was able to workaround that using the following code
image

@ppetzold
Copy link
Owner Author

ppetzold commented Dec 11, 2021

Yup. That would be an example for the query builder solution I was referring to in #114

This issue here tho refers more to the incorporation of all feature of class-transformer. Besides hiding/exposing properties, it has decorators for additional data transformation etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request will accept PR
Projects
None yet
Development

No branches or pull requests

2 participants