mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-09-09 19:31:58 +02:00
cleanup
This commit is contained in:
@@ -121,7 +121,7 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
- parameter persistentID: the `DynamicObjectID` pertaining ot the `NSManagedObject` or `CoreStoreObject` type to be edited
|
||||
- returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`.
|
||||
*/
|
||||
public func edit<O: DynamicObject>(
|
||||
public func edit<O>(
|
||||
_ persistentID: DynamicObjectID<O>?
|
||||
) -> O? {
|
||||
|
||||
@@ -157,6 +157,30 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
return self.context.fetchExisting(object)
|
||||
}
|
||||
|
||||
/**
|
||||
Returns an editable proxy of the object with the specified `DynamicObjectID`.
|
||||
|
||||
- parameter into: an `Into` clause specifying the entity type
|
||||
- parameter persistentID: the `DynamicObjectID` for the object to be edited
|
||||
- returns: an editable proxy for the specified `NSManagedObject` or `CoreStoreObject`.
|
||||
*/
|
||||
public func edit<O>(
|
||||
_ into: Into<O>,
|
||||
_ persistentID: DynamicObjectID<O>
|
||||
) -> O? {
|
||||
|
||||
Internals.assert(
|
||||
self.isRunningInAllowedQueue(),
|
||||
"Attempted to update an entity of type \(Internals.typeName(into.entityClass)) outside its designated queue."
|
||||
)
|
||||
Internals.assert(
|
||||
into.inferStoreIfPossible
|
||||
|| (into.configuration ?? DataStack.defaultConfigurationName) == persistentID.managedObjectID.persistentStore?.configurationName,
|
||||
"Attempted to update an entity of type \(Internals.typeName(into.entityClass)) but the specified persistent store do not match the `NSManagedObjectID`."
|
||||
)
|
||||
return self.fetchExisting(persistentID)
|
||||
}
|
||||
|
||||
/**
|
||||
Returns an editable proxy of the object with the specified `NSManagedObjectID`.
|
||||
|
||||
@@ -180,6 +204,26 @@ public /*abstract*/ class BaseDataTransaction {
|
||||
)
|
||||
return self.fetchExisting(objectID)
|
||||
}
|
||||
|
||||
/**
|
||||
Deletes the objects with the specified `DynamicObjectID`s.
|
||||
|
||||
- parameter persistentIDs: the `DynamicObjectID`s of the objects to delete
|
||||
*/
|
||||
public func delete<O: DynamicObject, S: Sequence>(
|
||||
persistentIDs: S
|
||||
) where S.Iterator.Element == DynamicObjectID<O> {
|
||||
|
||||
Internals.assert(
|
||||
self.isRunningInAllowedQueue(),
|
||||
"Attempted to delete an entity outside its designated queue."
|
||||
)
|
||||
let context = self.context
|
||||
persistentIDs.forEach {
|
||||
|
||||
context.fetchExisting($0).map({ context.delete($0.cs_toRaw()) })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Deletes the objects with the specified `NSManagedObjectID`s.
|
||||
|
||||
Reference in New Issue
Block a user