You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 17, 2017. It is now read-only.
I have the need to call a function objects, including nested objects, after they've been denormalized. Since it includes nested entities, if I waited until the entire object was denormalized I'd have to re-traverse all of the nested schemas manually, which I'd like to avoid.
To give more context of my specific use-case, I'm storing raw data in a normalized store and I need to instantiate classes from these object on the way out.
I think it would be a fairly simple/straightforward change to the denormalizeObject function:
functiondenormalizeObject(obj,entities,schema,bag){letdenormalized=objObject.keys(schema).filter(attribute=>attribute.substring(0,1)!=='_').filter(attribute=>typeofgetIn(obj,[attribute])!=='undefined').forEach(attribute=>{constitem=getIn(obj,[attribute]);constitemSchema=getIn(schema,[attribute]);denormalized=setIn(denormalized,[attribute],denormalize(item,entities,itemSchema,bag));});// New lineconst{ transform =_.identity}=bagreturntransform(denormalized);}
The one issue that I see is that the bag field is the last argument to denormalize. I think just passing the transform key directly there should be fine but there's a non-zero chance it would collide with a key during denormalization if that happened to be a string key. Super edge-case IMHO, but we could either make that key more specific (e.g. transformObject) or prefix it with a _ (e.g. _transform or _transformObject) if you think that's an issue.
Let me know if this makes sense and I can put together a PR with specs.
The text was updated successfully, but these errors were encountered:
I have the need to call a function objects, including nested objects, after they've been denormalized. Since it includes nested entities, if I waited until the entire object was denormalized I'd have to re-traverse all of the nested schemas manually, which I'd like to avoid.
To give more context of my specific use-case, I'm storing raw data in a normalized store and I need to instantiate classes from these object on the way out.
I think it would be a fairly simple/straightforward change to the
denormalizeObject
function:The one issue that I see is that the
bag
field is the last argument to denormalize. I think just passing thetransform
key directly there should be fine but there's a non-zero chance it would collide with a key during denormalization if that happened to be a string key. Super edge-case IMHO, but we could either make that key more specific (e.g.transformObject
) or prefix it with a_
(e.g._transform
or_transformObject
) if you think that's an issue.Let me know if this makes sense and I can put together a PR with specs.
The text was updated successfully, but these errors were encountered: