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

Relation to inherited entities #58

Open
o15a3d4l11s2 opened this issue Dec 1, 2015 · 3 comments
Open

Relation to inherited entities #58

o15a3d4l11s2 opened this issue Dec 1, 2015 · 3 comments
Labels

Comments

@o15a3d4l11s2
Copy link

Is there an annotation to cover the following case:
screen shot 2015-12-01 at 23 09 41

The JSON structure is the following:

{
  "users": [
    {
      "id": 1,
      "sentMessages": [
        {
          "id": 1,
          "type": "textMessage",
          "text": "asdfghjkl"
        },
        {
          "id": 2,
          "type": "pictureMessage",
          "url": "http://example.com/image.png"
        }
      ]
    }
  ]
}

The logic for the messages is taken from your example for entityMapperName, but I am not sure how to map the relationship between the objects.

How should I annotate the relations textMessages and pictureMessages together with the entityMapperName logic for the abstract base entity Message?

@gonzalezreal
Copy link
Owner

Groot does not currently support mapping one relationship into multiple relationships. You should map your sentMessages array to a single relationship and then filter by type when fetching your managed objects.

@o15a3d4l11s2
Copy link
Author

Is it reasonable to use the JSONDictionaryTransformerName to transform the JSON data to two separate relations (sentMessages would become textMessages and pictureMessages), as in the model?

@gonzalezreal
Copy link
Owner

Nope, sorry that wouldn't work.

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

No branches or pull requests

2 participants