Description
support:
1. CURD
2. Database Migration
3. Objective data present and Plain data present.
this project is also a demo, check the test case for more detail.
CTPersistance alternatives and similar libraries
Based on the "Database" category.
Alternatively, view CTPersistance alternatives based on common mentions on social networks and blogs.
-
Realm
The alternative to CoreData and SQLite: Simple, modern and fast. -
MMKV
An efficient, small mobile key-value storage framework developed by WeChat. Works on iOS, Android, macOS and Windows. -
WCDB
WCDB is an efficient, complete, easy-to-use mobile database framework for iOS, macOS. -
SQLite.swift
A type-safe, Swift-language layer over SQLite3. -
YapDatabase
YapDatabase is an extensible database for iOS & Mac. -
ParseAlternatives
A collaborative list of Parse alternative backend service providers. -
SugarRecord
Data persistence management library written in Swift 2.0 -
Couchbase Mobile
Couchbase document store for mobile with cloud sync. -
FCModel
An alternative to Core Data for people who like having direct SQL access. -
UserDefaults
Simple, Strongly Typed UserDefaults for iOS, macOS and tvOS -
MongoKitten
A pure Swift MongoDB client implementation with support for embedded databases. -
Prephirences
Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state. -
Unrealm
Unrealm enables you to easily store Swift native Classes, Structs and Enums into Realm. -
RealmIncrementalStore
Realm-powered Core Data persistent store. -
Palau
NSUserDefaults with Wings! Custom Validation, Swift Generics. -
UserDefaultsStore
An easy and very light way to store and retrieve -reasonable amount- of Codable objects, in a couple lines of code. -
PredicateEditor
A visual editor for dynamically creating NSPredicates to query data in your iOS app. -
ObjectBox
ObjectBox is a superfast, light-weight object persistence framework. -
Nora
Nora is a Firebase abstraction layer for working with FirebaseDatabase and FirebaseStorage. -
realm-cocoa-converter
A library that provides the ability to import/export Realm files from a variety of data container formats. -
MySQL
A Swift wrapper around the MySQL client library, enabling access to MySQL servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
SecureDefaults
A lightweight wrapper over UserDefaults/NSUserDefaults with an extra AES-256 encryption layer. -
RealmGeoQueries
RealmGeoQueries simplifies spatial queries with Realm Cocoa. In the absence of and official functions, this library provide the possibility to do proximity search. -
PersistentStorageSerializable
Swift library that makes easier to serialize the user's preferences (app's settings) with system User Defaults or Property List file on disk. -
PersistenceKit
Store and retrieve Codable objects to various persistence layers, in a couple lines of code. -
YapDatabaseExtensions
YapDatabase extensions for use with Swift -
TypedDefaults
TypedDefaults is a utility library to type-safely use NSUserDefaults. -
MongoDB
A Swift wrapper around the mongo-c client library, enabling access to MongoDB servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
PostgreSQL
A Swift wrapper around the libpq client library, enabling access to PostgreSQL servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
FileMaker
A Swift wrapper around the FileMaker XML Web publishing interface, enabling access to FileMaker servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
SQLite
A Swift wrapper around the SQLite 3 client library, enabling access to SQLite servers. Part of the Perfect project, but stand-alone. SPM and Swift 3 support. -
Storez
Safe, statically-typed, store-agnostic key-value storage (with namespace support). -
Redis
A Swift wrapper around the Redis client library, enabling access to Redis. Part of the Perfect project, but stand-alone. SPM and Swift 3 support.
Scout APM - Leading-edge performance monitoring starting at $39/month
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest. Visit our partner's website for more details.
Do you think we are missing an alternative of CTPersistance or a related project?
README
pod "CTPersistance"
CTPersistance
is a sqlite wrapper which help you to handle with database.
I'm still writing this document, you can check test case for usage.
Async Operation in CTPersistance
DO NOT USE GCD DIRECTLY
DO NOT USE GCD DIRECTLY
DO NOT USE GCD DIRECTLY
CTPersistance provide CTPersistanceAsyncExecutor
to do the async staff.
read:
[[CTPersistanceAsyncExecutor sharedInstance] read:^{
NSInteger count = COUNT;
while (count --> 0) {
TestRecord *record = (TestRecord *)[self.testTable findWithPrimaryKey:@(count) error:NULL];
NSLog(@"%@", record.primaryKey);
}
}];
write:
[[CTPersistanceAsyncExecutor sharedInstance] write:^{
NSInteger count = COUNT;
while (count --> 0) {
NSNumber *primaryKey = [self.testTable insertValue:@"casa" forKey:@"name" error:NULL];
NSLog(@"%@", primaryKey);
}
}];
see AsyncTestViewController for demo
run CTPersistance project in Simulator, and async test
is the live demo for async operation.
Target-Action in CTPersistance
CTPersistance use CTMediator to handle how the database migrate, what secret key to encrypt, where to place the database file.
You should create a target, and just put it into your project, no more code and CTMediator
will call your target.
the different database name should have different target, and the target should conform to protocol CTPersistanceConfigurationTarget
. see here CTPersistance.h:43
the name of the target object is based on the name of your database file.for example:
say you have a database file which name is:
`aaa.sqlite`, and the target should be `Target_aaa`
`aaa_bbb.sqlite`, and the target should be `Target_aaa`
`aaa_bbb`, and the target should be `Target_aaa`
`aaa.abc.sqlite`, and the target should be `Target_aaa`
`aaa`, and the target should be `Target_aaa`
Available Actions:
- (NSString *)Action_filePath:(NSDictionary *)params
return the absolute file path as you want. The database file name will be send in the params.
If CTPersistance can not call this method, CTPersistance will find database in [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject] stringByAppendingPathComponent:databaseName]
folder, if still not found, CTPersistance will create the database file in this path with the database file name.
- (CTPersistanceMigrator *)Action_fetchMigrator:(NSDictionary *)params
return the class name of migrator manager for database migration.
see Target_MigrationTestDatabase.m:20
- (NSArray *)Action_secretKey:(NSDictionary *)params
return secret key to encrypt the database file.
if you have changed the secret key, keep the old key and append new key in a array and return it.
say you encrypt the database in version 1 (it's the version about your app) by the key oldkey
, and you changed this key to newkey
in version 2. Some days later you changed the key to newkey2
in version3, you should return an array like this:
@[
@"oldkey",
@"newkey",
@"newkey2",
]
Record
CTPersistance's record does not have to be a specific object. Any object who conforms to CTPersistanceRecordProtocol
can be handled by CTPersistance.
That means you can handle any object like UIView
、UIViewController
with CTPersistance as long as they conforms to CTPersistanceRecordProtocol
. For example you can insert a UIView
, and fetch the same data as a dictionary or even UIViewController
.
Though CTPersistance does not require your object to inherit from a specific model, CTPersistance provide you CTPersistanceRecord
if you do not want to implement the protocol.
CRUD Operations
Create : see here
Read : see here
Update : see here
Delete : see here
Upsert : see here
Other Operations
Database Migration : see here
Index of Columns : see here
Transaction : see here
Change Key of Encryption : see here