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

Map object to object #244

Closed
ma-abdn opened this issue Dec 18, 2020 · 6 comments
Closed

Map object to object #244

ma-abdn opened this issue Dec 18, 2020 · 6 comments
Assignees

Comments

@ma-abdn
Copy link

ma-abdn commented Dec 18, 2020

I'm submitting a...


[ ] Regression 
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request

The map function accept a source object and the definition of Source and Destination
It would be great if there is another map function that accept the source object + destination object.
My goal is instead of map source object to a new created destination, you map the source object to an existant destination object (so it will be updated)

@nartc
Copy link
Owner

nartc commented Dec 18, 2020

Hi @ma-abdn thanks for the feature request. I understand this request completely and I notice it's something available in the AutoMapper .NET as well which qualifies the request a valid request. However due to reasons stated here #243 , I won't be adding this feature to @nartc/automapper and will be supporting this feature in the upcoming changes. I'll reference this in #243 and will be closing this issue.

@nartc
Copy link
Owner

nartc commented Jan 5, 2021

@ma-abdn I'm reopening this to clarify. When we run mapper.someMapFn(sourceObj, destinationObj) (someMapFn name is subject to change), are you expecting destinationObj to be mutated? or someMapFn() returns a new object?

@nartc nartc reopened this Jan 5, 2021
@ma-abdn
Copy link
Author

ma-abdn commented Jan 7, 2021

It will more practical if the destinationObj is mutated because when dealing with an ORM if we want to merge some data to an existing object it wouldn't be possible. In other hand if we won't mutate the destinationObj we clone it just before.

@nartc
Copy link
Owner

nartc commented Jan 7, 2021

@ma-abdn So we're on the same page here. Do you expect to have this functionality for mapArray as well? ( I personally don't).

@ma-abdn
Copy link
Author

ma-abdn commented Jan 7, 2021

Not necessary. the map do the job.

@nartc
Copy link
Owner

nartc commented Jan 7, 2021

1.0.0-beta.6 has been released. Please try it out:

map(sourceObj, destination, source, destinationObject)
mapAsync(sourceObj, destination, source, destinationObject)

Above snippet is the API to have this map mutate functionality. Please test it out and let me know. If you run into any issue, please open a new issue :)

@nartc nartc closed this as completed Jan 7, 2021
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

No branches or pull requests

2 participants