# Classes

The following classes are available globally.

### AsynchronousDataTransaction

- `AsynchronousDataTransaction`

  The `AsynchronousDataTransaction` provides an interface for `DynamicObject` creates, updates, and deletes. A transaction object should typically be only used from within a transaction block initiated from `DataStack.perform(asynchronous:...)`, or from `CoreStore.perform(synchronous:...)`.

  See more

  #### Declaration

  Swift

      public final class AsynchronousDataTransaction : BaseDataTransaction

### BaseDataTransaction

- `BaseDataTransaction`

  The `BaseDataTransaction` is an abstract interface for `NSManagedObject` creates, updates, and deletes. All `BaseDataTransaction` subclasses manage a private `NSManagedObjectContext` which are direct children of the `NSPersistentStoreCoordinator`‘s root `NSManagedObjectContext`. This means that all updates are saved first to the persistent store, and then propagated up to the read-only `NSManagedObjectContext`.

  See more

  #### Declaration

  Swift

      public class BaseDataTransaction

### CSAsynchronousDataTransaction

- `CSAsynchronousDataTransaction`

  The `CSAsynchronousDataTransaction` serves as the Objective-C bridging type for `AsynchronousDataTransaction`.

  See also

  `AsynchronousDataTransaction`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSAsynchronousDataTransaction : CSBaseDataTransaction, CoreStoreObjectiveCType

### CSBaseDataTransaction

- `CSBaseDataTransaction`

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

  See also

  `BaseDataTransaction`
  See more

  #### Declaration

  Swift

      @objc
      public class CSBaseDataTransaction : NSObject

### CSCoreStore

- `CSCoreStore`

  The `CSCoreStore` serves as the Objective-C bridging type for `CoreStore`.

  See also

  `CoreStore`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSCoreStore : NSObject

### CSDataStack

- `CSDataStack`

  The `CSDataStack` serves as the Objective-C bridging type for `DataStack`.

  See also

  `DataStack`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSDataStack : NSObject, CoreStoreObjectiveCType

### DataStack

- `DataStack`

  The `DataStack` encapsulates the data model for the Core Data stack. Each `DataStack` can have multiple data stores, usually specified as a Configuration in the model editor. Behind the scenes, the DataStack manages its own `NSPersistentStoreCoordinator`, a root `NSManagedObjectContext` for disk saves, and a shared `NSManagedObjectContext` designed as a read-only model interface for `NSManagedObjects`.

  See more

  #### Declaration

  Swift

      public final class DataStack : Equatable

### CSError

- `CSError`

  All errors thrown from CoreStore are expressed in `CSError`s.

  See also

  `CoreStoreError`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSError : NSError, CoreStoreObjectiveCType

### CSFrom

- `CSFrom`

  The `CSFrom` serves as the Objective-C bridging type for `From`.

  See also

  `From`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSFrom : NSObject

### CSGroupBy

- `CSGroupBy`

  The `CSGroupBy` serves as the Objective-C bridging type for `GroupBy`.

  See also

  `GroupBy`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSGroupBy : NSObject, CSQueryClause

### CSInMemoryStore

- `CSInMemoryStore`

  The `CSInMemoryStore` serves as the Objective-C bridging type for `InMemoryStore`.

  See also

  `InMemoryStore`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSInMemoryStore : NSObject, CSStorageInterface, CoreStoreObjectiveCType

### InMemoryStore

- `InMemoryStore`

  A storage interface that is backed only in memory.

  See more

  #### Declaration

  Swift

      public final class InMemoryStore : StorageInterface

### CSInto

- `CSInto`

  The `CSInto` serves as the Objective-C bridging type for `Into<T>`.

  See also

  `Into`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSInto : NSObject

### CSListMonitor

- `CSListMonitor`

  The `CSListMonitor` serves as the Objective-C bridging type for `ListMonitor<T>`.

  See also

  `ListMonitor`
  See more

  #### Declaration

  Swift

      @available(OSX 10.12, *)
      @objc
      public final class CSListMonitor : NSObject

### CSMigrationResult

- `CSMigrationResult`

  The `CSMigrationResult` serves as the Objective-C bridging type for `MigrationResult`.

  See also

  `MigrationResult`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSMigrationResult : NSObject, CoreStoreObjectiveCType

### CSMigrationType

- `CSMigrationType`

  The `CSMigrationType` serves as the Objective-C bridging type for `MigrationType`.

  See also

  `MigrationType`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSMigrationType : NSObject, CoreStoreObjectiveCType

### CSObjectMonitor

- `CSObjectMonitor`

  The `CSObjectMonitor` serves as the Objective-C bridging type for `ObjectMonitor<T>`.

  See also

  `ObjectMonitor`
  See more

  #### Declaration

  Swift

      @available(OSX 10.12, *)
      @objc
      public final class CSObjectMonitor : NSObject

### CSOrderBy

- `CSOrderBy`

  The `CSOrderBy` serves as the Objective-C bridging type for `OrderBy`.

  See also

  `OrderBy`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSOrderBy : NSObject, CSFetchClause, CSQueryClause, CSDeleteClause

### CSSQLiteStore

- `CSSQLiteStore`

  The `CSSQLiteStore` serves as the Objective-C bridging type for `SQLiteStore`.

  See also

  `SQLiteStore`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSSQLiteStore : NSObject, CSLocalStorage, CoreStoreObjectiveCType

### SQLiteStore

- `SQLiteStore`

  A storage interface that is backed by an SQLite database.

  Warning

  The default SQLite file location for the `LegacySQLiteStore` and `SQLiteStore` are different. If the app was depending on CoreStore’s default directories prior to 2.0.0, make sure to use the `SQLiteStore.legacy(...)` factory methods to create the `SQLiteStore` instead of using initializers directly.
  See more

  #### Declaration

  Swift

      public final class SQLiteStore : LocalStorage

### CSSectionBy

- `CSSectionBy`

  The `CSSectionBy` serves as the Objective-C bridging type for `SectionBy`.

  See also

  `SectionBy`
  See more

  #### Declaration

  Swift

      @available(OSX 10.12, *)
      @objc
      public final class CSSectionBy : NSObject

### CSSelectTerm

- `CSSelectTerm`

  The `CSSelectTerm` serves as the Objective-C bridging type for `SelectTerm`.

  See also

  `SelectTerm`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSSelectTerm : NSObject

### CSSelect

- `CSSelect`

  The `CSSelect` serves as the Objective-C bridging type for `Select`.

  See also

  `Select`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSSelect : NSObject

### CSSetupResult

- `CSSetupResult`

  The `CSSetupResult` serves as the Objective-C bridging type for `SetupResult`.

  See also

  `SetupResult`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSSetupResult : NSObject

### CSSynchronousDataTransaction

- `CSSynchronousDataTransaction`

  The `CSSynchronousDataTransaction` serves as the Objective-C bridging type for `SynchronousDataTransaction`.

  See also

  `SynchronousDataTransaction`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSSynchronousDataTransaction : CSBaseDataTransaction, CoreStoreObjectiveCType

### SynchronousDataTransaction

- `SynchronousDataTransaction`

  The `SynchronousDataTransaction` provides an interface for `DynamicObject` creates, updates, and deletes. A transaction object should typically be only used from within a transaction block initiated from `DataStack.beginSynchronous(_:)`, or from `CoreStore.beginSynchronous(_:)`.

  See more

  #### Declaration

  Swift

      public final class SynchronousDataTransaction : BaseDataTransaction

### CSTweak

- `CSTweak`

  The `CSTweak` serves as the Objective-C bridging type for `Tweak`.

  See also

  `Tweak`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSTweak : NSObject, CSFetchClause, CSQueryClause, CSDeleteClause, CoreStoreObjectiveCType

### CSUnsafeDataModelSchema

- `CSUnsafeDataModelSchema`

  The `CSUnsafeDataModelSchema` serves as the Objective-C bridging type for `UnsafeDataModelSchema`.

  See also

  `UnsafeDataModelSchema`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSUnsafeDataModelSchema : NSObject, CSDynamicSchema, CoreStoreObjectiveCType

### UnsafeDataModelSchema

- `UnsafeDataModelSchema`

  The `UnsafeDataModelSchema` describes models loaded directly from an existing `NSManagedObjectModel`. It is not advisable to continue using this model as its metadata are not available to CoreStore.

  See more

  #### Declaration

  Swift

      public final class UnsafeDataModelSchema : DynamicSchema

### CSUnsafeDataTransaction

- `CSUnsafeDataTransaction`

  The `CSUnsafeDataTransaction` serves as the Objective-C bridging type for `UnsafeDataTransaction`.

  See also

  `UnsafeDataTransaction`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSUnsafeDataTransaction : CSBaseDataTransaction, CoreStoreObjectiveCType

### UnsafeDataTransaction

- `UnsafeDataTransaction`

  The `UnsafeDataTransaction` provides an interface for non-contiguous `NSManagedObject` or `CoreStoreObject` creates, updates, and deletes. This is useful for making temporary changes, such as partially filled forms. An unsafe transaction object should typically be only used from the main queue.

  See more

  #### Declaration

  Swift

      public final class UnsafeDataTransaction : BaseDataTransaction

### CSWhere

- `CSWhere`

  The `CSWhere` serves as the Objective-C bridging type for `Where`.

  See also

  `Where`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSWhere : NSObject, CSFetchClause, CSQueryClause, CSDeleteClause

### CSXcodeDataModelSchema

- `CSXcodeDataModelSchema`

  The `CSXcodeDataModelSchema` serves as the Objective-C bridging type for `XcodeDataModelSchema`.

  See also

  `XcodeDataModelSchema`
  See more

  #### Declaration

  Swift

      @objc
      public final class CSXcodeDataModelSchema : NSObject, CSDynamicSchema, CoreStoreObjectiveCType

### XcodeDataModelSchema

- `XcodeDataModelSchema`

  The `XcodeDataModelSchema` describes a model version declared in a single *.xcdatamodeld file.

      CoreStore.defaultStack = DataStack(
          XcodeDataModelSchema(modelName: "MyAppV1", bundle: .main)
      )

  See more

  #### Declaration

  Swift

      public final class XcodeDataModelSchema : DynamicSchema

### CoreStoreObject

- `CoreStoreObject`

  The `CoreStoreObject` is an abstract class for creating CoreStore-managed objects that are more type-safe and more convenient than `NSManagedObject` subclasses. The model entities for `CoreStoreObject` subclasses are inferred from the Swift declaration themselves; no .xcdatamodeld files are needed. To declare persisted attributes and relationships for the `CoreStoreObject` subclass, declare properties of type `Value.Required<T>`, `Value.Optional<T>` for values, or `Relationship.ToOne<T>`, `Relationship.ToManyOrdered<T>`, `Relationship.ToManyUnordered<T>` for relationships.

      class Animal: CoreStoreObject {
          let species = Value.Required<String>("species", initial: "")
          let nickname = Value.Optional<String>("nickname")
          let master = Relationship.ToOne<Person>("master")
      }

      class Person: CoreStoreObject {
          let name = Value.Required<String>("name", initial: "")
          let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master })
      }

  `CoreStoreObject` entities for a model version should be added to `CoreStoreSchema` instance.

      CoreStore.defaultStack = DataStack(
          CoreStoreSchema(
              modelVersion: "V1",
              entities: [
                  Entity<Animal>("Animal"),
                  Entity<Person>("Person")
              ]
          )
      )

  See also

  CoreStoreSchema

  See also

  CoreStoreObject.Value

  See also

  CoreStoreObject.Relationship
  See more

  #### Declaration

  Swift

      open class CoreStoreObject : DynamicObject, Hashable

### CoreStoreSchema

- `CoreStoreSchema`

  The `CoreStoreSchema` describes models written for `CoreStoreObject` Swift class declarations for a particular model version. `CoreStoreObject` entities for a model version should be added to `CoreStoreSchema` instance.

      class Animal: CoreStoreObject {
          let species = Value.Required<String>("species", initial: "")
          let nickname = Value.Optional<String>("nickname")
          let master = Relationship.ToOne<Person>("master")
      }

      class Person: CoreStoreObject {
          let name = Value.Required<String>("name", initial: "")
          let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master })
      }

      CoreStore.defaultStack = DataStack(
          CoreStoreSchema(
              modelVersion: "V1",
              entities: [
                  Entity<Animal>("Animal"),
                  Entity<Person>("Person")
              ],
              versionLock: [
                  "Animal": [0x2698c812ebbc3b97, 0x751e3fa3f04cf9, 0x51fd460d3babc82, 0x92b4ba735b5a3053],
                  "Person": [0xae4060a59f990ef0, 0x8ac83a6e1411c130, 0xa29fea58e2e38ab6, 0x2071bb7e33d77887]
              ]
          )
      )

  See also

  CoreStoreObject

  See also

  Entity
  See more

  #### Declaration

  Swift

      public final class CoreStoreSchema : DynamicSchema

### Entity

- `Entity`

  The `Entity<O>` contains `NSEntityDescription` metadata for `CoreStoreObject` subclasses. Pass the `Entity` instances to `CoreStoreSchema` initializer.

      class Animal: CoreStoreObject {
          let species = Value.Required<String>("species", initial: "")
          let nickname = Value.Optional<String>("nickname")
          let master = Relationship.ToOne<Person>("master")
      }

      class Person: CoreStoreObject {
          let name = Value.Required<String>("name", initial: "")
          let pet = Relationship.ToOne<Animal>("pet", inverse: { $0.master })
      }

      CoreStore.defaultStack = DataStack(
          CoreStoreSchema(
              modelVersion: "V1",
              entities: [
                  Entity<Animal>("Animal"),
                  Entity<Person>("Person")
              ]
          )
      )

  See also

  CoreStoreSchema

  See also

  CoreStoreObject
  See more

  #### Declaration

  Swift

      public final class Entity<O> : DynamicEntity where O : CoreStoreObject

### ListMonitor

- `ListMonitor`

  The `ListMonitor` monitors changes to a list of `DynamicObject` instances. Observers that implement the `ListObserver` protocol may then register themselves to the `ListMonitor`‘s `addObserver(_:)` method:

      let monitor = CoreStore.monitorList(
          From<Person>(),
          Where("title", isEqualTo: "Engineer"),
          OrderBy(.ascending("lastName"))
      )
      monitor.addObserver(self)

  The `ListMonitor` instance needs to be held on (retained) for as long as the list needs to be observed. Observers registered via `addObserver(_:)` are not retained. `ListMonitor` only keeps a `weak` reference to all observers, thus keeping itself free from retain-cycles.

  Lists created with `monitorList(...)` keep a single-section list of objects, where each object can be accessed by index:

      let firstPerson: MyPersonEntity = monitor[0]

  Accessing the list with an index above the valid range will raise an exception.

  Creating a sectioned-list is also possible with the `monitorSectionedList(...)` method:

      let monitor = CoreStore.monitorSectionedList(
          From<Person>(),
          SectionBy("age") { "Age \($0)" },
          Where("title", isEqualTo: "Engineer"),
          OrderBy(.ascending("lastName"))
      )
      monitor.addObserver(self)

  Objects from `ListMonitor`s created this way can be accessed either by an `IndexPath` or a tuple:

      let indexPath = IndexPath(forItem: 3, inSection: 2)
      let person1 = monitor[indexPath]
      let person2 = monitor[2, 3]

  In the example above, both `person1` and `person2` will contain the object at section=2, index=3.

  See more

  #### Declaration

  Swift

      @available(OSX 10.12, *)
      public final class ListMonitor<D> : Hashable where D : DynamicObject

### ObjectMonitor

- `ObjectMonitor`

  The `ObjectMonitor` monitors changes to a single `DynamicObject` instance. Observers that implement the `ObjectObserver` protocol may then register themselves to the `ObjectMonitor`‘s `addObserver(_:)` method:

      let monitor = CoreStore.monitorObject(object)
      monitor.addObserver(self)

  The created `ObjectMonitor` instance needs to be held on (retained) for as long as the object needs to be observed.

  Observers registered via `addObserver(_:)` are not retained. `ObjectMonitor` only keeps a `weak` reference to all observers, thus keeping itself free from retain-cycles.

  See more

  #### Declaration

  Swift

      @available(OSX 10.12, *)
      public final class ObjectMonitor<D> : Equatable where D : DynamicObject

### SchemaHistory

- `SchemaHistory`

  The `SchemaHistory` encapsulates multiple `DynamicSchema` across multiple model versions. It contains all model history and is used by the `DataStack` to

  See more

  #### Declaration

  Swift

      public final class SchemaHistory : ExpressibleByArrayLiteral

### CoreStoreObjectValueDiff

- `CoreStoreObjectValueDiff`

  The object containing the changeset for an observed `ValueContainer.Required` and `ValueContainer.Optional` property.

  See more

  #### Declaration

  Swift

      public final class CoreStoreObjectValueDiff<V> where V : ImportableAttributeType

### CoreStoreObjectValueDiff

- `CoreStoreObjectTransformableDiff`

  The object containing the changeset for an observed `TransformableContainer.Required` or `TransformableContainer.Optional` property.

  See more

  #### Declaration

  Swift

      public final class CoreStoreObjectTransformableDiff<V> where V : NSCoding, V : NSCopying

### CoreStoreObjectObjectDiff

- `CoreStoreObjectObjectDiff`

  The object containing the changeset for an observed `RelationshipContainer.ToOne` property.

  See more

  #### Declaration

  Swift

      public final class CoreStoreObjectObjectDiff<D> where D : CoreStoreObject

### CoreStoreObjectUnorderedDiff

- `CoreStoreObjectUnorderedDiff`

  The object containing the changeset for an observed `RelationshipContainer.ToManyUnordered` property.

  See more

  #### Declaration

  Swift

      public final class CoreStoreObjectUnorderedDiff<D> where D : CoreStoreObject

### CoreStoreObjectOrderedDiff

- `CoreStoreObjectOrderedDiff`

  The object containing the changeset for an observed `RelationshipContainer.Ordered` property.

  See more

  #### Declaration

  Swift

      public final class CoreStoreObjectOrderedDiff<D> where D : CoreStoreObject

### CustomSchemaMappingProvider

- `CustomSchemaMappingProvider`

  A `SchemaMappingProvider` that accepts custom mappings for some entities. Mappings of entities with no `CustomMapping` provided will be automatically calculated if possible.

  See more

  #### Declaration

  Swift

      public class CustomSchemaMappingProvider : Hashable, SchemaMappingProvider

### DefaultLogger

- `DefaultLogger`

  The `DefaultLogger` is a basic implementation of the `CoreStoreLogger` protocol.

  See more

  #### Declaration

  Swift

      public final class DefaultLogger : CoreStoreLogger

### DynamicEntity

- `DynamicEntity`

  Use concrete instances of `Entity<O>` in API that accept `DynamicEntity` arguments.

  See more

  #### Declaration

  Swift

      public class DynamicEntity : Hashable

### InferredSchemaMappingProvider

- `InferredSchemaMappingProvider`

  A `SchemaMappingProvider` that tries to infer model migration between two `DynamicSchema` versions by searching all `xcmappingmodel`s from `Bundle.allBundles` or by relying on lightweight migration if possible. Throws an error if lightweight migration is impossible for the two `DynamicSchema`. This mapping is automatically used as a fallback mapping provider, even if no mapping providers are explicitly declared in the `StorageInterface`.

  Note

  For security reasons, `InferredSchemaMappingProvider` will not search `Bundle.allFrameworks` by default. If the `xcmappingmodel`s are bundled within a framework, use `XcodeSchemaMappingProvider` instead and provide `Bundle(for: <a class in the framework>` to its initializer.
  See more

  #### Declaration

  Swift

      public final class InferredSchemaMappingProvider : Hashable, SchemaMappingProvider

### UserInfo

- `UserInfo`

  The `UserInfo` class is provided by several CoreStore types such as `DataStack`, `ListMonitor`, `ObjectMonitor` and transactions to allow external libraries or user apps to store their own custom data.

      enum Static {
          static var myDataKey: Void?
      }
      CoreStore.defaultStack.userInfo[&Static.myDataKey] = myObject

  Important

  Do not use this class to store thread-sensitive data.
  See more

  #### Declaration

  Swift

      public final class UserInfo

### XcodeSchemaMappingProvider

- `XcodeSchemaMappingProvider`

  A `SchemaMappingProvider` that tries to infer model migration between two `DynamicSchema` versions by loading an xcmappingmodel file from the specified `Bundle`. Throws `CoreStoreError.mappingModelNotFound` if the xcmappingmodel file cannot be found, or if the xcmappingmodel doesn’t resolve the source and destination `DynamicSchema`.

  See more

  #### Declaration

  Swift

      public final class XcodeSchemaMappingProvider : Hashable, SchemaMappingProvider