-
Notifications
You must be signed in to change notification settings - Fork 61
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
Identity attribute relationships #15
Conversation
…p serialization when just id is provided
* commit 'd6de11e1fc22b8b63b0e135c7d473eccb88935b0': Add Carthage installation instructions Replace static lib target by a framework target
Includes test cases in the |
This is a very interesting feature. Groot is currently being reimplemented using Swift. Let me know if you'd be interested in providing this feature in that branch as well. |
Sure, I'll implement it when I have some time. |
I've done it. Any comments are welcome. |
Thanks! I will look into it as soon as I have some spare time. |
There has been a lot of internal changes for milestone 1.0, so this PR is kind of updated. In any case your contribution was very useful and effectively has been the seed for #26. Thanks a lot! |
If your JSON has the relationships by referencing the identity attribute instead of by nesting JSONs, you can take advantage of the
identityAttributeRelated
attribute. For example, if your JSONNSDictionary
is:you may not want Groot to serialize this dictionary by setting 1 to the
Publisher
relationship, but by assigning it with thePublisher
object which has 1 as itsidentityAttribute
value. You accomplish that by associating the identityAttribute key withtrue
(or any other positive boolean value) in the entity user info dictionary:This way, Groot will search in the publisher entity for a entry with the given identity attribute. If it is found, it will assign this entry as the
Publisher
object of theCharacter
; if it doesn't Groot will create a placeholderPublisher
entry with this value for the identity attribute. This placeholder object would be filled eventually if the new data is provided.Note: To make this feature works, you must always to use the merge methods instead of the insert ones.