wankdanker/node-object-mapper

Mapping source values to destination object keys dynamically

NFNChris opened this issue · 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

Any update on this??

Is this possible?

Any updates on this?