mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Question: Can you clarify the difference between fetchExisting(T) and edit(T) #102
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 @popwarfour on GitHub (Nov 18, 2016).
I'm currently running from swift3_develop
In both async and sync transaction classes the edit functions look to just be calling the fetchExisting behind the scenes anyway. Is there a difference between the two I'm not seeing?
Great library, looking forward to using this more moving forward!
@JohnEstropia commented on GitHub (Nov 21, 2016):
@popwarfour Nothing, really. Just semantic naming:
edit()adds nuance that this object can be edited. But that's entirely up to you.@popwarfour commented on GitHub (Nov 21, 2016):
figured as much, thanks
@rivera-ernesto commented on GitHub (Jan 16, 2018):
I see that
editruns more checks.Where
fetchExisting:edit:Any comment @JohnEstropia ?
@JohnEstropia commented on GitHub (Jan 17, 2018):
Yes they do technically the same thing. The only difference is the semantic use,
edit()being available only to transactions. Instances created withedit()are expected to be "edited" so extra checks are put in place for you for "just in case" scenarios. It is not available to read-only contexts (i.e. DataStack)fetchExisting()on the other hand is mostly used for moving instances across main and background contexts. For this reason it is available under the same name to both read-only and read-write contexts.Of course you can just use
fetchExisting()everywhere if you wish. Butedit()is there so you can take advantage of the expressiveness and safety.