mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Update from JSON an already saved object. #41
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @minuscorp on GitHub (Feb 18, 2016).
I'd like to know if its possible given a query object with some properties:
let object = CoreStore...I can update it self through theImportableObjectprotocol, which has the mapping for the JSON but to a certain already saved object (several backends gives the primary key in respose after you upload a local created object to the backend).Also, is there a way to export an object to [String: AnyObject] that also encodes their relationships?
Thank you! Grat job with this repo! 👍
@JohnEstropia commented on GitHub (Feb 19, 2016):
You can call the
ImportableObjectmethods directly if you want to:It might be more convenient to let the transaction have a method for this though. Feel free to post a github issue for the feature request.
The
ImportableObjectandImportableUniqueObjectprotocol methods accept atransactionargument for this very purpose. You can fetch and import from within those methods:@minuscorp commented on GitHub (Feb 19, 2016):
With the second question I meant if there's a method to export an object to JSON format (a simple
[String: AnyObject]that follows the same rules as the exposed in theImportableObjectprotocol but in the inverse path)@JohnEstropia commented on GitHub (Feb 19, 2016):
@minuscorp Oh sorry.. For some reason I read that wrong.
I think it's not in CoreStore's scope to implement export utilities. In the end it would end up as a floating protocol that is used nowhere else in CoreStore. I suggest you just implement it directly on your NSManagedObject subclass, or write an extension that uses your app's mapping rules.
@JohnEstropia commented on GitHub (Feb 20, 2016):
Closing this issue for now. If you have further questions feel free to message anytime :)