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
Realm is a mobile database: a replacement for Core Data & SQLite -
MMKV
An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX. -
SQLite.swift
A type-safe, Swift-language layer over SQLite3. -
GRDB.swift
A toolkit for SQLite databases, with a focus on application development -
SwiftyUserDefaults
Modern Swift API for NSUserDefaults -
YapDatabase
YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers. -
ParseAlternatives
GraphQLite is a toolkit to work with GraphQL servers easily. It also provides several other features to make life easier during iOS application development. [Moved to: https://github.com/relatedcode/GraphQLite] -
Couchbase Mobile
Lightweight, embedded, syncable NoSQL database engine for iOS and MacOS apps. -
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
Native MongoDB driver for Swift, written in Swift -
Unrealm
Unrealm is an extension on RealmCocoa, which enables Swift native types to be saved in Realm. -
Prephirences
Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state. UserDefaults -
RealmIncrementalStore
Realm-powered Core Data persistent store -
ObjectBox
Swift database - fast, simple and lightweight (iOS, macOS) -
UserDefaultsStore
Why not use UserDefaults to store Codable objects ๐ -
PredicateEditor
A GUI for dynamically creating NSPredicates at runtime to query data in your iOS app. -
Nora
Nora is a Firebase abstraction layer for FirebaseDatabase and FirebaseStorage -
realm-cocoa-converter
A library that provides the ability to import/export Realm files from a variety of data container formats. -
SecureDefaults
Elevate the security of your UserDefaults with this lightweight โจ wrapper that adds an additional layer of AES-256 encryption -
MySQL
A stand-alone Swift wrapper around the MySQL client library, enabling access to MySQL servers. -
PersistenceKit
Store and retrieve Codable objects to various persistence layers, in a couple lines of code! -
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. -
YapDatabaseExtensions
YapDatabase extensions for use with Swift -
TypedDefaults
TypedDefaults is a utility library to type-safely use NSUserDefaults. -
MongoDB
A stand-alone Swift wrapper around the mongo-c client library, enabling access to MongoDB servers. -
PostgreSQL
A stand-alone Swift wrapper around the libpq client library, enabling access to PostgreSQL servers. -
ObjectiveRocks
An Objective-C wrapper for RocksDB - A Persistent Key-Value Store for Flash and RAM Storage. -
SQLite
A stand-alone Swift wrapper around the SQLite 3 client library. -
Storez
๐พ Safe, statically-typed, store-agnostic key-value storage written in Swift! -
FileMaker
A stand-alone Swift wrapper around the FileMaker XML Web publishing interface, enabling access to FileMaker servers.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
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