gonzalezreal / Groot

From JSON to Core Data and back.
Other
534 stars 61 forks source link

Introduce `identityProperties` over `identityProperties ` annotation #60

Closed fabiomassimo closed 8 years ago

fabiomassimo commented 8 years ago

In my Data Model I have an entity A that has a relationship one-to-many to entity B. When implementing the proper userInfo keys for B I'd like to use as identityAttributes a combination of an attribute in B and an attribute in A (for which B has an inverse relationship), such that I can uniquely identify an object in B for every unique object A.

Wouldn't it be better to use propertyByName instead of attributeByName to match the values that uniquely identifies an entity? It could be something like identityProperties that gives the opportunity to also include attributes within other objects in a relationship.

gonzalezreal commented 8 years ago

I am not sure if that is even possible to accomplish. Will have a look into it.

fabiomassimo commented 8 years ago

Thanks for your reply. May I ask your opinion about this small update in my fork? The idea is that when Groot tries to set a relationship, by serializing a JSON object, the relationship is preserved to make sure only objects in the relationship are updated.

Thank you for your time.

https://github.com/fabiomassimo/Groot/commit/1ab1484b4490b55b53286196de1f7a17cf2592a4

Sorry for lack of tests, I'll add it as soon as possible and if you find it ok maybe open a PR.