mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Add Sync Behavior #72
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 @jannon on GitHub (Aug 6, 2016).
Hey, so one of the things I liked about the Sync Project was it's ability to fully sync a list of JSON objects with your Core Data store include insert, update, and delete.
There were a lot of other things I like about CoreStore more, so I decided on using it, but I've come to the point in my integration now that I need the delete functionality. For now, I've just handled it myself after getting the results from
importUniqueObjects, but it would be awesome if CoreStore could provide the functionality.I was thinking it could either be an additional parameter on
importUniqueObjectsto specify the operations to perform (.Insert, .Update, .Delete) or a separate method (e.g.syncUniqueObjects) that also performs the deletes.I started to think about adding it and submitting a PR when I realized that I just have absolutely no time to do it right, with tests and docs, and figuring out how to make sure Objective-C works (because it's the worst). Below is something like what I had in mind.
DISCLAIMER: I don't know if the below code even compiles. It's mainly to illustrate what I was thinking in terms of interface and functionality:
Thanks!
@JohnEstropia commented on GitHub (Aug 7, 2016):
Thanks for the idea!
I also like Sync's features and for some time now have been considering implementing a small subset of their features. The remote and local keys mapping in particular looks really attractive. But for it's implementation CoreStore needs a big overhaul of the current importing architecture and I haven't had the time to grind on it yet.
As for your sample implementation, It looks to me like you are just deleting objects that are not in the source array. Is this correct? If so, this can be done similarly with just one line after
importUniqueObjects():I've considered adding an auto-deletion mechanism before as well, but it's just too usecase-specific:
So I let "ImportableUniqueObject" API just do the importing, and leave everything else to the app. I recommend putting your
syncUniqueObjectsmethods in an extension.In your case though it looks like you need to return the unique IDs of the deleted objects as well. If so, maybe we can add a separate delete method for
ImportableUniqueObjects:What do you think?
@JohnEstropia commented on GitHub (Aug 24, 2016):
Hi, I'm closing this issue for now. If you have any suggestions or pull requests please don't hesitate :)