SQLiteStore
public final class SQLiteStore : LocalStorage
extension SQLiteStore: CustomDebugStringConvertible, CoreStoreDebugStringConvertible
A storage interface that is backed by an SQLite database.
Warning
The default SQLite file location for theLegacySQLiteStore 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.
-
Initializes an SQLite store interface from the given SQLite file URL. When this instance is passed to the
DataStack‘saddStorage()methods, a new SQLite file will be created if it does not exist.Declaration
Swift
public init(fileURL: URL, configuration: ModelConfiguration = nil, migrationMappingProviders: [SchemaMappingProvider] = [], localStorageOptions: LocalStorageOptions = nil)Parameters
fileURLthe local file URL for the target SQLite persistent store. Note that if you have multiple configurations, you will need to specify a different
fileURLexplicitly for each of them.configurationan optional configuration name from the model file. If not specified, defaults to
nil, the “Default” configuration. Note that if you have multiple configurations, you will need to specify a differentfileURLexplicitly for each of them.migrationMappingProvidersan array of
SchemaMappingProvidersthat provides the complete mapping models for custom migrations. All lightweight inferred mappings and/or migration mappings provided by *xcmappingmodel files are automatically used as fallback (asInferredSchemaMappingProvider) and may be omitted from the array.localStorageOptions -
Initializes an SQLite store interface from the given SQLite file name. When this instance is passed to the
DataStack‘saddStorage()methods, a new SQLite file will be created if it does not exist.Warning
The default SQLite file location for theLegacySQLiteStoreandSQLiteStoreare different. If the app was depending on CoreStore’s default directories prior to 2.0.0, make sure to use theSQLiteStore.legacy(...)factory methods to create theSQLiteStoreinstead of using initializers directly.Declaration
Swift
public init(fileName: String, configuration: ModelConfiguration = nil, migrationMappingProviders: [SchemaMappingProvider] = [], localStorageOptions: LocalStorageOptions = nil)Parameters
fileNamethe local filename for the SQLite persistent store in the “Application Support/
” directory (or the “Caches/ ” directory on tvOS). Note that if you have multiple configurations, you will need to specify a different fileNameexplicitly for each of them.configurationan optional configuration name from the model file. If not specified, defaults to
nil, the “Default” configuration. Note that if you have multiple configurations, you will need to specify a differentfileNameexplicitly for each of them.migrationMappingProvidersan array of
SchemaMappingProvidersthat provides the complete mapping models for custom migrations. All lightweight inferred mappings and/or migration mappings provided by *xcmappingmodel files are automatically used as fallback (asInferredSchemaMappingProvider) and may be omitted from the array.localStorageOptions -
Initializes an
SQLiteStorewith an all-default settings: afileURLpointing to a “.sqlite” file in the “Application Support/ ” directory (or the “Caches/ ” directory on tvOS), a nilconfigurationpertaining to the “Default” configuration, amigrationMappingProvidersset to empty, andlocalStorageOptionsset to.AllowProgresiveMigration.Warning
The default SQLite file location for theLegacySQLiteStoreandSQLiteStoreare different. If the app was depending on CoreStore’s default directories prior to 2.0.0, make sure to use theSQLiteStore.legacy(...)factory methods to create theSQLiteStoreinstead of using initializers directly.Declaration
Swift
public init() -
Initializes an SQLite store interface from the given SQLite file name. When this instance is passed to the
DataStack‘saddStorage()methods, a new SQLite file will be created if it does not exist.Warning
The default SQLite file location for theLegacySQLiteStoreandSQLiteStoreare different. If the app was depending on CoreStore’s default directories prior to 2.0.0, make sure to use theSQLiteStore.legacy(...)factory methods to create theSQLiteStoreinstead of using initializers directly.Declaration
Swift
public static func legacy(fileName: String, configuration: ModelConfiguration = nil, migrationMappingProviders: [SchemaMappingProvider] = [], localStorageOptions: LocalStorageOptions = nil) -> SQLiteStoreParameters
legacyFileNamethe local filename for the SQLite persistent store in the “Application Support” directory (or the “Caches” directory on tvOS). Note that if you have multiple configurations, you will need to specify a different
fileNameexplicitly for each of them.configurationan optional configuration name from the model file. If not specified, defaults to
nil, the “Default” configuration. Note that if you have multiple configurations, you will need to specify a differentfileNameexplicitly for each of them.migrationMappingProvidersan array of
SchemaMappingProvidersthat provides the complete mapping models for custom migrations. All lightweight inferred mappings and/or migration mappings provided by *xcmappingmodel files are automatically used as fallback (asInferredSchemaMappingProvider) and may be omitted from the array.localStorageOptions -
Initializes an
LegacySQLiteStorewith an all-default settings: afileURLpointing to a “.sqlite” file in the “Application Support” directory (or the “Caches” directory on tvOS), a nilconfigurationpertaining to the “Default” configuration, amigrationMappingProvidersset to empty, andlocalStorageOptionsset to.AllowProgresiveMigration.Warning
The default SQLite file location for theLegacySQLiteStoreandSQLiteStoreare different. If the app was depending on CoreStore’s default directories prior to 2.0.0, make sure to use theSQLiteStore.legacy(...)factory methods to create theSQLiteStoreinstead of using initializers directly.Declaration
Swift
public static func legacy() -> SQLiteStore -
Queries the file size (in bytes) of the store, or
nilif the file does not exist yetDeclaration
Swift
public func fileSize() -> UInt64?
-
The string identifier for the
NSPersistentStore‘stypeproperty. ForSQLiteStores, this is always set toNSSQLiteStoreType.Declaration
Swift
public static let storeType: String -
The configuration name in the model file
Declaration
Swift
public let configuration: ModelConfiguration -
The options dictionary for the
NSPersistentStore. ForSQLiteStores, this is always set to[NSSQLitePragmasOption: ["journal_mode": "WAL"]]Declaration
Swift
public let storeOptions: [AnyHashable : Any]? -
The
NSURLthat points to the SQLite fileDeclaration
Swift
public let fileURL: URL -
An array of
SchemaMappingProvidersthat provides the complete mapping models for custom migrations.Declaration
Swift
public let migrationMappingProviders: [SchemaMappingProvider] -
Options that tell the
DataStackhow to setup the persistent storeDeclaration
Swift
public var localStorageOptions: LocalStorageOptions -
The options dictionary for the specified
LocalStorageOptionsDeclaration
Swift
public func dictionary(forOptions options: LocalStorageOptions) -> [AnyHashable : Any]? -
Called by the
DataStackto perform checkpoint operations on the storage. ForSQLiteStore, this converts the database’s WAL journaling mode to DELETE to force a checkpoint.Declaration
Swift
public func cs_finalizeStorageAndWait(soureModelHint: NSManagedObjectModel) throws -
Called by the
DataStackto perform actual deletion of the store file from disk. Do not call directly! ThesourceModelargument is a hint for the existing store’s model version. ForSQLiteStore, this converts the database’s WAL journaling mode to DELETE before deleting the file.Declaration
Swift
public func cs_eraseStorageAndWait(metadata: [String : Any], soureModelHint: NSManagedObjectModel?) throws
-
Declaration
Swift
public var debugDescription: String { get }
View on GitHub
SQLiteStore Class Reference