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

Heterogenous data lists #1

Open
innovate-invent opened this issue Apr 14, 2020 · 5 comments
Open

Heterogenous data lists #1

innovate-invent opened this issue Apr 14, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@innovate-invent
Copy link
Contributor

innovate-invent commented Apr 14, 2020

Is your feature request related to a problem? Please describe...

The backend I interact with returns a heterogenous list of objects. This can't currently be processed by VuexORM. Each object has an attribute declaring its type.

{
  "type":"container",
  "elements": [
    { "id": 1, "type":"type1", "type1param":"", "common_param":"" },
    { "id": 2, "type":"type1", "type1param":"", "common_param":"" },
    { "id": 3, "type":"type2", "type2param":"", "common_param":"" },
  ]
}

or simply a fetch response can be

[
  { "id": 1, "type":"type1", "type1param":"", "common_param":"" },
  { "id": 2, "type":"type1", "type1param":"", "common_param":"" },
  { "id": 3, "type":"type2", "type2param":"", "common_param":"" },
]

Describe the solution you'd like

Provide a relation that keys on the object type attribute and handles it accordingly.
The relation should accept a mapping of type attribute values to ORM models.

Describe alternatives you've considered

I am currently transforming the data using a request hook to split the lists.

@kiaking kiaking added the enhancement New feature or request label Apr 15, 2020
@kiaking
Copy link
Member

kiaking commented Apr 15, 2020

@innovate-invent Thanks for the feedback! Yes, currently the "morph" relations are not implemented yet at this repo. I think once that's implemented, this should be possible too.

@kiaking
Copy link
Member

kiaking commented Nov 1, 2021

I've opened #90 for MorphOne relation.

@kiaking kiaking closed this as completed Nov 1, 2021
@kiaking kiaking added this to the v1.0.0-alpha.1 milestone Nov 1, 2021
@innovate-invent
Copy link
Contributor Author

@kiaking I am not sure the morphone relationship allows for what I am describing. MorphOne seems to allow an item to backreference a variable type, where I need to be able to deserailize a list of varying types.

Am I misunderstanding how to do that with MorphOne as it exists?

@kiaking
Copy link
Member

kiaking commented Nov 15, 2021

@innovate-invent Ah sorry, yes MorphOne is not exactly what you're looking for. However, we're working on implementing all Polymorphic relation like MorphTo and MorphMany and such so eventually you'll get what you want! Stay tuned 👍

@innovate-invent
Copy link
Contributor Author

Would you mind reopening this to ensure it isn't overlooked? I should point out that this type of relation wasn't available in the previous version either.

@kiaking kiaking reopened this Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants