Mutation
Apply a registered mapping to an existing destination object or array.
Mapping creates a destination object; mutation applies the same mapping instructions to an object you provide.
const dto = mapper.map(user, User, UserDto);
const existingDto = new UserDto();
mapper.mutate(user, existingDto, User, UserDto);
Mutation methods return void because the supplied destination is updated in place:
| Create destination | Mutate destination |
|---|---|
map() |
mutate() |
mapAsync() |
mutateAsync() |
mapArray() |
mutateArray() |
mapArrayAsync() |
mutateArrayAsync() |
Use the async variants when member resolvers or mapping callbacks return promises.
await mapper.mutateAsync(user, existingDto, User, UserDto);
await mapper.mutateArrayAsync(users, existingDtos, User, UserDto);