Skip to content
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

Mapping multiple entities from one response #177

Open
ivan006 opened this issue Jan 18, 2023 · 1 comment
Open

Mapping multiple entities from one response #177

ivan006 opened this issue Jan 18, 2023 · 1 comment

Comments

@ivan006
Copy link

ivan006 commented Jan 18, 2023

How do I map multiple entities types from a single response?
Say for instance I hit a user_with_tasks endpoint which returns me a user but all their tasks also. What would I use to map to both models. I found some code somewhere that shows I would use "dataTransformer" and then inside use

data.tasks.map((task) => {
     Object.assign(task);
     Object.assign(task.attributes);
});

does this look right? I might be completely misunderstanding.

@ivan006
Copy link
Author

ivan006 commented Jan 23, 2023

Yeah I was on the wrong track although the above assign operation is important in my context the active ingredient, to map to multiple models, is simply the relationship settings if that is setup the mapping to multiple models is automatic <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant