node-object-mapper icon indicating copy to clipboard operation
node-object-mapper copied to clipboard

The reverse

Open albertossilva opened this issue 8 years ago • 4 comments

How can do a bidirectional mapper?

albertossilva avatar Oct 26 '16 20:10 albertossilva

+1

johnnychq avatar Jul 21 '17 14:07 johnnychq

Can you elaborate? E.g. sample use case?

matmar10 avatar Jul 21 '17 14:07 matmar10

This would be useful to have a mapper between a local format and a vendor format. E.g. you get an awkward XML file defined by a service provider and you map it to a simple to understand DTO. This is what actually works with node-object-mapper. The other other direction would be to get this DTO - maybe manipulated - back to the service provider XML form.

leachiM2k avatar Feb 05 '18 07:02 leachiM2k

You can use something like lodash's invert method to reverse the key-value pair of the mapping object: https://lodash.com/docs/4.17.10#invert

laander avatar May 29 '18 11:05 laander