# CSBaseDataTransaction Class Reference

# CSBaseDataTransaction

    @objc
    public class CSBaseDataTransaction : NSObject

The `CSBaseDataTransaction` serves as the Objective-C bridging type for `BaseDataTransaction`.

See also

`BaseDataTransaction`

### Object management

- `hasChanges`

  Indicates if the transaction has pending changes

  #### Declaration

  Swift

      @objc
      public var hasChanges: Bool { get }

- `createInto(_:)`

  Creates a new `NSManagedObject` with the specified entity type.

  #### Declaration

  Swift

      @objc
      public func createInto(_ into: CSInto) -> Any

  #### Parameters

  `into` | the `CSInto` clause indicating the destination `NSManagedObject` entity type and the destination configuration

  #### Return Value

  a new `NSManagedObject` instance of the specified entity type.

- `editObject(_:)`

  Returns an editable proxy of a specified `NSManagedObject`.

  #### Declaration

  Swift

      @objc
      public func editObject(_ object: NSManagedObject?) -> Any?

  #### Parameters

  `object` | the `NSManagedObject` type to be edited

  #### Return Value

  an editable proxy for the specified `NSManagedObject`.

- `editInto(_:objectID:)`

  Returns an editable proxy of the object with the specified `NSManagedObjectID`.

  #### Declaration

  Swift

      @objc
      public func editInto(_ into: CSInto, objectID: NSManagedObjectID) -> Any?

  #### Parameters

  `into` | a `CSInto` clause specifying the entity type
  `objectID` | the `NSManagedObjectID` for the object to be edited

  #### Return Value

  an editable proxy for the specified `NSManagedObject`.

- `deleteObject(_:)`

  Deletes a specified `NSManagedObject`.

  #### Declaration

  Swift

      @objc
      public func deleteObject(_ object: NSManagedObject?)

  #### Parameters

  `object` | the `NSManagedObject` to be deleted

- `deleteObjects(_:)`

  Deletes the specified `NSManagedObject`s.

  #### Declaration

  Swift

      @objc
      public func deleteObjects(_ objects: [NSManagedObject])

  #### Parameters

  `objects` | the `NSManagedObject`s to be deleted

- `refreshAndMergeAllObjects()`

  Refreshes all registered objects `NSManagedObject`s in the transaction.

  #### Declaration

  Swift

      @objc
      public func refreshAndMergeAllObjects()

### Inspecting Pending Objects

- `insertedObjectsOfType(_:)`

  Returns all pending `NSManagedObject`s of the specified type that were inserted to the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func insertedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject>

  #### Parameters

  `entity` | the `NSManagedObject` subclass to filter

  #### Return Value

  an `NSSet` of pending `NSManagedObject`s of the specified type that were inserted to the transaction.

- `insertedObjectIDs()`

  Returns all pending `NSManagedObjectID`s that were inserted to the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func insertedObjectIDs() -> Set<NSManagedObjectID>

  #### Return Value

  an `NSSet` of pending `NSManagedObjectID`s that were inserted to the transaction.

- `insertedObjectIDsOfType(_:)`

  Returns all pending `NSManagedObjectID`s of the specified type that were inserted to the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func insertedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID>

  #### Parameters

  `entity` | the `NSManagedObject` subclass to filter

  #### Return Value

  an `NSSet` of pending `NSManagedObjectID`s of the specified type that were inserted to the transaction.

- `updatedObjectsOfType(_:)`

  Returns all pending `NSManagedObject`s of the specified type that were updated in the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func updatedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject>

  #### Parameters

  `entity` | the `NSManagedObject` subclass to filter

  #### Return Value

  an `NSSet` of pending `NSManagedObject`s of the specified type that were updated in the transaction.

- `updatedObjectIDs()`

  Returns all pending `NSManagedObjectID`s that were updated in the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func updatedObjectIDs() -> Set<NSManagedObjectID>

  #### Return Value

  an `NSSet` of pending `NSManagedObjectID`s that were updated in the transaction.

- `updatedObjectIDsOfType(_:)`

  Returns all pending `NSManagedObjectID`s of the specified type that were updated in the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func updatedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID>

  #### Parameters

  `entity` | the `NSManagedObject` subclass to filter

  #### Return Value

  an `NSSet` of pending `NSManagedObjectID`s of the specified type that were updated in the transaction.

- `deletedObjectsOfType(_:)`

  Returns all pending `NSManagedObject`s of the specified type that were deleted from the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func deletedObjectsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObject>

  #### Parameters

  `entity` | the `NSManagedObject` subclass to filter

  #### Return Value

  an `NSSet` of pending `NSManagedObject`s of the specified type that were deleted from the transaction.

- `deletedObjectIDs()`

  Returns all pending `NSManagedObjectID`s of the specified type that were deleted from the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func deletedObjectIDs() -> Set<NSManagedObjectID>

  #### Return Value

  an `NSSet` of pending `NSManagedObjectID`s of the specified type that were deleted from the transaction.

- `deletedObjectIDsOfType(_:)`

  Returns all pending `NSManagedObjectID`s of the specified type that were deleted from the transaction. This method should not be called after the `-commit*:` method was called.

  #### Declaration

  Swift

      @objc
      public func deletedObjectIDsOfType(_ entity: NSManagedObject.Type) -> Set<NSManagedObjectID>

  #### Parameters

  `entity` | the `NSManagedObject` subclass to filter

  #### Return Value

  a `Set` of pending `NSManagedObjectID`s of the specified type that were deleted from the transaction.

### CSBaseDataTransaction

- `fetchExistingObject(_:)`

  Fetches the `NSManagedObject` instance in the transaction’s context from a reference created from a transaction or from a different managed object context.

  #### Declaration

  Swift

      @objc
      public func fetchExistingObject(_ object: NSManagedObject) -> Any?

  #### Parameters

  `object` | a reference to the object created/fetched outside the transaction

  #### Return Value

  the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.

- `fetchExistingObjectWithID(_:)`

  Fetches the `NSManagedObject` instance in the transaction’s context from an `NSManagedObjectID`.

  #### Declaration

  Swift

      @objc
      public func fetchExistingObjectWithID(_ objectID: NSManagedObjectID) -> Any?

  #### Parameters

  `objectID` | the `NSManagedObjectID` for the object

  #### Return Value

  the `NSManagedObject` instance if the object exists in the transaction, or `nil` if not found.

- `fetchExistingObjects(_:)`

  Fetches the `NSManagedObject` instances in the transaction’s context from references created from a transaction or from a different managed object context.

  #### Declaration

  Swift

      @objc
      public func fetchExistingObjects(_ objects: [NSManagedObject]) -> [Any]

  #### Parameters

  `objects` | an array of `NSManagedObject`s created/fetched outside the transaction

  #### Return Value

  the `NSManagedObject` array for objects that exists in the transaction

- `fetchExistingObjectsWithIDs(_:)`

  Fetches the `NSManagedObject` instances in the transaction’s context from a list of `NSManagedObjectID`.

  #### Declaration

  Swift

      @objc
      public func fetchExistingObjectsWithIDs(_ objectIDs: [NSManagedObjectID]) -> [Any]

  #### Parameters

  `objectIDs` | the `NSManagedObjectID` array for the objects

  #### Return Value

  the `NSManagedObject` array for objects that exists in the transaction

- `fetchOneFrom(_:fetchClauses:)`

  Fetches the first `NSManagedObject` instance that satisfies the specified `CSFetchClause`s. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.

  #### Declaration

  Swift

      @objc
      public func fetchOneFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> Any?

  #### Parameters

  `from` | a `From` clause indicating the entity type
  `fetchClauses` | a series of `CSFetchClause` instances for the fetch request. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.

  #### Return Value

  the first `NSManagedObject` instance that satisfies the specified `CSFetchClause`s

- `fetchAllFrom(_:fetchClauses:)`

  Fetches all `NSManagedObject` instances that satisfy the specified `CSFetchClause`s. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.

  #### Declaration

  Swift

      @objc
      public func fetchAllFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> [Any]?

  #### Parameters

  `from` | a `CSFrom` clause indicating the entity type
  `fetchClauses` | a series of `CSFetchClause` instances for the fetch request. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.

  #### Return Value

  all `NSManagedObject` instances that satisfy the specified `CSFetchClause`s

- `fetchCountFrom(_:fetchClauses:)`

  Fetches the number of `NSManagedObject`s that satisfy the specified `CSFetchClause`s. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.

  #### Declaration

  Swift

      @objc
      public func fetchCountFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> NSNumber?

  #### Parameters

  `from` | a `CSFrom` clause indicating the entity type
  `fetchClauses` | a series of `CSFetchClause` instances for the fetch request. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.

  #### Return Value

  the number `NSManagedObject`s that satisfy the specified `CSFetchClause`s

- `fetchObjectIDFrom(_:fetchClauses:)`

  Fetches the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `CSFetchClause`s. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.

  #### Declaration

  Swift

      @objc
      public func fetchObjectIDFrom(_ from: CSFrom, fetchClauses: [CSFetchClause]) -> NSManagedObjectID?

  #### Parameters

  `from` | a `CSFrom` clause indicating the entity type
  `fetchClauses` | a series of `CSFetchClause` instances for the fetch request. Accepts `CSWhere`, `CSOrderBy`, and `CSTweak` clauses.

  #### Return Value

  the `NSManagedObjectID` for the first `NSManagedObject` that satisfies the specified `CSFetchClause`s

- `queryValueFrom(_:selectClause:queryClauses:)`

  Queries aggregate values as specified by the `CSQueryClause`s. Requires at least a `CSSelect` clause, and optional `CSWhere`, `CSOrderBy`, `CSGroupBy`, and `CSTweak` clauses.

  A query differs from a fetch in that it only retrieves values already stored in the persistent store. As such, values from unsaved transactions or contexts will not be incorporated in the query result.

  #### Declaration

  Swift

      @objc
      public func queryValueFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> Any?

  #### Parameters

  `from` | a `CSFrom` clause indicating the entity type
  `selectClause` | a `CSSelect` clause indicating the properties to fetch, and with the generic type indicating the return type.
  `queryClauses` | a series of `CSQueryClause` instances for the query request. Accepts `CSWhere`, `CSOrderBy`, `CSGroupBy`, and `CSTweak` clauses.

  #### Return Value

  the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.

- `queryAttributesFrom(_:selectClause:queryClauses:)`

  Queries a dictionary of attribute values as specified by the `CSQueryClause`s. Requires at least a `CSSelect` clause, and optional `CSWhere`, `CSOrderBy`, `CSGroupBy`, and `CSTweak` clauses.

  A query differs from a fetch in that it only retrieves values already stored in the persistent store. As such, values from unsaved transactions or contexts will not be incorporated in the query result.

  #### Declaration

  Swift

      @objc
      public func queryAttributesFrom(_ from: CSFrom, selectClause: CSSelect, queryClauses: [CSQueryClause]) -> [[String : Any]]?

  #### Parameters

  `from` | a `CSFrom` clause indicating the entity type
  `selectClause` | a `CSSelect` clause indicating the properties to fetch, and with the generic type indicating the return type.
  `queryClauses` | a series of `CSQueryClause` instances for the query request. Accepts `CSWhere`, `CSOrderBy`, `CSGroupBy`, and `CSTweak` clauses.

  #### Return Value

  the result of the the query. The type of the return value is specified by the generic type of the `CSSelect` parameter.