You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use mapWith when the source and destination values are arrays. Is there a way to do this?
What I've done:
mapper.createMap(User,UserDto).forMember((d)=>d.someArrayField,mapWith(()=>XDto,(s)=>[],// the mapper will return an XDto instance instead of this value()=>X))
but changing .avatar to .addresses, AvatarVm to AddressVm and Avatar to Address(I didn't test this tbh)
My use case is basically like this:
classA{// ...
@AutoMap(()=>B)b: B[]}classB{// ...
@AutoMap(()=>C)c: C}classC{}classAVm{
@AutoMap(()=>CVm)c: CVm[]// I want to extract this from B[]}classCVm{}
The text was updated successfully, but these errors were encountered:
Hey!
I'm trying to use
mapWith
when thesource
anddestination
values are arrays. Is there a way to do this?What I've done:
I see that is a limitation due to these lines:
mapper/packages/core/src/lib/member-map-functions/map-with.ts
Lines 24 to 26 in 1331bbf
since if I use
mapper.mapArray
instead, it will work as I expected.To test that you could use this:
mapper/packages/integration-test/src/lib/with-classes/fixtures/profiles/user-profile.profile.ts
Lines 21 to 25 in 6187453
but changing
.avatar
to.addresses
,AvatarVm
toAddressVm
andAvatar
toAddress
(I didn't test this tbh)My use case is basically like this:
The text was updated successfully, but these errors were encountered: