A lightweight iOS database framework based on FMDB and SQLite.
This framework supports the development of iOS 7.0+ in ARC.
- Database table CREATE/DROP/ALERT.
- Database records queries with SELECT.
- Database records INSERT/REPLACE/UPDATE/DELETE.
[[JCDBManager sharedManager] createWithDBName:@"testDB.sqlite"];
[[JCDBManager sharedManager] closeDB];
[JCTestRecord createTable];
[JCTestRecord alterTableWithColumn:@"testUnsignedLongLongInt"];
[JCTestRecord dropTable];
JCTestRecord *record = [[JCTestRecord alloc] init];
record.testPrimaryKey = [NSString stringWithFormat:@"primaryKeyProperty%@", @(index + 1)];
record.testIgnore = @"ignoreProperty";
record.testMutableString = [[NSMutableString alloc] initWithString:@"mutableStringProperty"];
record.testNumber = @(6.20);
record.testDecimalNumber = [[NSDecimalNumber alloc] initWithString:@"2016"];
record.testDate = [NSDate date];
record.testData = [@"dataProperty" dataUsingEncoding:NSUTF8StringEncoding];
record.testMutableData = [NSMutableData dataWithData:[@"mutableDataProperty" dataUsingEncoding:NSUTF8StringEncoding]];
record.testBOOL = YES;
record.testShort = 6;
record.testInt = 20;
record.testLong = 20160620;
record.testInteger = index + 1;
record.testEnumType = (index + 1) % 3;
record.testInt64 = (index + 1)*24*3600;
record.testUInteger = 201606;
record.testFloat = 10.5;
record.testCGFloat = 1.26;
record.testDouble = 10.52;
record.testTimeInterval = 978307200.0;
record.testLongInt = 10000010;
record.testLongLongInt = 1000000110;
record.testUnsignedLongLongInt = 100000000111;
BOOL result = [record updateRecord];
result = [record updateRecordColumns:@[@"testBOOL", @"testDate", @"testNumber"]
values:@[@(NO), [NSDate dateWithTimeIntervalSince1970:9], @(6.22)]];
result = [record deleteRecord];
JCTestRecord *record = [JCTestRecord queryRecordWithPrimaryKeyValue:@"primaryKeyProperty2"];
NSArray *queryRecords = [JCTestRecord queryRecordsWithConditions:@{@"testEnumType":@(JCTestEnumTypeTwo)}];
queryRecords = [JCTestRecord queryRecordsWithConditionalExpression:@"WHERE testEnumType < ?"
arguments:@[@(JCTestEnumTypeTwo)]];
queryRecords = [JCTestRecord queryRecordsWithConditionalExpression:@"ORDER BY testEnumType DESC"
arguments:nil];
queryRecords = [JCTestRecord queryAllRecords];
NSArray *queryColumns = [JCTestRecord queryColumns:@[@"testPrimaryKey", @"testDate"]
conditionalExpression:@"WHERE testEnumType < ? ORDER BY testInteger DESC"
arguments:@[@(JCTestEnumTypeOne)]];
uint64_t count = [JCTestRecord countRecordsWithConditions:@{@"testEnumType":@(JCTestEnumTypeTwo)}];
count = [JCTestRecord countRecordsWithConditionalExpression:@"WHERE testEnumType < ?"
arguments:@[@(JCTestEnumTypeOne)]];
count = [JCTestRecord countAllRecords];
BOOL result = [JCTestRecord deleteRecordsWithConditions:@{@"testEnumType":@(JCTestEnumTypeTwo)}];
result = [JCTestRecord deleteRecordsWithConditionalExpression:@"WHERE testEnumType < ?"
arguments:@[@(JCTestEnumTypeOne)]];
result = [JCTestRecord deleteAllRecords];
To integrate JCDB into your iOS project, specify it in your Podfile:
pod 'JCDB'
##Contacts If you have any questions or suggestions about the framework, please E-mail to contact me.
Author: Joych E-mail: imjoych@gmail.com
JCDB is released under the MIT License.