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

Mapping source values to destination object keys dynamically

Open NFNChris opened this issue 9 years ago • 3 comments

Is it possible to map this:

[ { condition: 'new', quantity: 5, id: 'x' }, { condition: 'used', quantity: 3, id: 'y' }, { condition: 'broken', quantity: 1, id: 'z' } ]

To this: { 'new': { quantity: 5, id: 'x' }, 'used': { quantity: 3, id: 'y' }, 'broken': { quantity: 1, id: 'z' } }

I didn't see any clear examples of mapping a source value to an object key in the destination.

This would be useful, for example, in quickly referencing the 'new' value object by key rather than having to search through the array to find it.

I have been trying to figure this out for the past few hours - any direction would be much appreciated!

Thanks,

Chris

NFNChris avatar Nov 05 '15 04:11 NFNChris

Any update on this??

nisargrthakkar avatar Apr 13 '20 08:04 nisargrthakkar

Is this possible?

Asafkbalink avatar May 31 '20 06:05 Asafkbalink

Any updates on this?

HemalathaBR avatar Aug 13 '20 23:08 HemalathaBR