-
Notifications
You must be signed in to change notification settings - Fork 13
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
How to handle array of string? #13
Comments
hmm, I hadn't considered doing that when I designed the library. I like the idea but haven't fully considered its needs and consequences. I suspect there will be trouble with implementing a design like this because a set of unique keys is needed for each row of input. It isn't clear to me how that a mapping would be possible if the source data had two properties that differed per id. In the following example if we wanted
I'm not sure there would be a logical output. The closest the NestHydration can do at the moment would be to have the input modified to something like the following:
which could be mapped by nestHydration to this:
which using js array map could get the output you want:
which would result in the desired output of
I still kinda like your idea though, and I think I will have time in the next 2 weeks to consider this further and maybe make a change that would allow for what you proposed. If you want to put a pull request forward yourself I'd certainly appreciate it. |
Hi, Thanks for your reply, after I post my issue I realized nestHydration can only support the And the solution you mentioned I think it can only help the simple object mapping, if I have a complex object then I have to write a lot of code to make the output right. P.S: |
Update I've come to the conclusion that this array is possible, a good idea, and can be implemented in a consistent manner. I've implemented a filter that can run after the structure is built but came across a hiccup that makes it not a great option. I've decided on implementing this array building option inside the core algorithm but it will take a bit of time to get to it. |
I'm a little late to the party, but for anyone else who has this issue, I have a fork that handles arrays. https://github.com/jordansoltman/NestHydrationJS It also handles composite keys as well. I've made a pull request to bring in the changes. |
It looks like this module cannot to convert the data as string[]? Otherwise am I just miss something?
let's say I have some data like this:
my question is how to make a definition so that it can be used to convert the data like this below.
The text was updated successfully, but these errors were encountered: