-
Notifications
You must be signed in to change notification settings - Fork 12
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
Update Relationship data structures to follow the spec. #17
Update Relationship data structures to follow the spec. #17
Conversation
type ResourceLinkage []*ResourceIdentifier | ||
|
||
// ResourceIdentifier identifies an individual resource. | ||
type ResourceIdentifier struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After seeing this, I was originally thinking we should make this a generic identifier, but for these cases an ID is required where as a for a top level data object it's not and having this be relationship specific makes sense to me.
c443fbf
to
a9b7f4a
Compare
Thanks for implementing this! I had been waiting until this library had stabilized a bit more(which it has), and I personally had a use-case for relationships to make sure I understood how I wanted to approach them other than providing the basic stub that was there before. Other than the minor nitpick this seems great. Get that fixed, and deal with the conflict (which is from your other PR) and we'll get this merged. |
Thanks, just sort out that merge conflict (should be trivial) and I'll get this in and bump the version. |
Previously, relationships were represented by a map[string]*Object which limits us to only being able to represent 1-1 relationships. In addition, the relationship format was not adhering to the format defined by the spec. http://jsonapi.org/format/#document-resource-object-relationships This commit models relationships as their own structures, and implements a custom Unmarshal to be able to handle 1-M relationships.
a9b7f4a
to
2cf6c17
Compare
No worries! Yeah I finally had a use case for relationships and noticed the issue. I've fixed the merge conflict. Thanks for all the good work! |
Awesome, thanks again. Feel free to open issues if you see any glaring architectural issues or any nice to haves that are currently missing. Not sure if you have a use case for this, but checkout: https://github.com/derekdowling/jsh-api as well. |
Update Relationship data structures to follow the spec.
Previously, relationships were represented by a
map[string]*Object
which is limited to only being able to represent1-1
relationships. In addition, the relationship format was not adhering to the format defined by the spec. See http://jsonapi.org/format/#document-resource-object-relationshipsThis PR represents relationships as their own data structures, and implements a custom UnmarshalJSON to be able to handle
1-M
relationships.