mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-11 20:00:30 +01:00
Observing changes by a single transaction #37
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 @jamesbebbington on GitHub (Feb 4, 2016).
Is there a way of compiling a changeset of CRUD operations that occurred within a given
transaction? I see thatcommit()returns aSaveResultbut that doesn't look to say much about the operations that occurred. Would it be difficult to extendSaveResultin this way?Alternatively, is it possible to scope a ListMonitor to a transaction somehow?
Thanks.
@JohnEstropia commented on GitHub (Feb 5, 2016):
@fractious Yup, I understand the need. I'm trying to implement automatic CoreSpotlight indexing and bookkeeping changesets is one of the requirements to make it work. Once I get it working I may expose the CRUD changes somewhere.
There's no working prototype yet but you can glimpse of the progress in the
_corespotlight-testbranch. In theNSManagedObjectContext+CoreSpotlight.swiftfile, I intend to twiddle with theinsertedObjects:,updatedObjects, anddeletedObjectsinfo from the context.It doesn't make sense with async and sync transactions (their context dies with the closure they run in), but we can allow
UnsafeDataTransactionto create their own ListMonitors/ObjectMonitors. I'm not sure if it will help your requirements right now but it seems simple and sensible enough to implement.@jamesbebbington commented on GitHub (Feb 8, 2016):
Yeah that sounds very helpful, I look forward to it.
@JohnEstropia commented on GitHub (Feb 16, 2016):
Check out the utilities I added here:
def105e73aIf there's anything else feel free to ask anytime!
@jamesbebbington commented on GitHub (Feb 16, 2016):
Sweet, they look good - are they methods on the
transactionobject?@JohnEstropia commented on GitHub (Feb 16, 2016):
Yes, so you will need to get the object references before you call
commit(). Transaction fetching rules apply, so if you need to access those objects you'll need to usefetchExisting():@jamesbebbington commented on GitHub (Feb 16, 2016):
Cheers John, I'll give it a try on the next release. Thanks!