Latest 1.0.1
Homepage https://github.com/imjoych/JCDB
License MIT
Platforms ios 7.0, requires ARC
Dependencies FMDB
Authors

A lightweight iOS database framework based on FMDB and SQLite.

Features

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.

Create and close database

[[JCDBManager sharedManager] createWithDBName:@"testDB.sqlite"];
[[JCDBManager sharedManager] closeDB];

Table operation

CREATE table
[JCTestRecord createTable];
ALERT table
[JCTestRecord alterTableWithColumn:@"testUnsignedLongLongInt"];
DROP table
[JCTestRecord dropTable];

Current record operation

INSERT OR REPLACE statement
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];
UPDATE statement
result = [record updateRecordColumns:@[@"testBOOL", @"testDate", @"testNumber"]
                              values:@[@(NO), [NSDate dateWithTimeIntervalSince1970:9], @(6.22)]];
DELETE statement
result = [record deleteRecord];

Records operation

SELECT records queries
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];
SELECT record columns queries
NSArray *queryColumns = [JCTestRecord queryColumns:@[@"testPrimaryKey", @"testDate"]
                             conditionalExpression:@"WHERE testEnumType < ? ORDER BY testInteger DESC"
                                         arguments:@[@(JCTestEnumTypeOne)]];
SELECT count queries
uint64_t count = [JCTestRecord countRecordsWithConditions:@{@"testEnumType":@(JCTestEnumTypeTwo)}];
count = [JCTestRecord countRecordsWithConditionalExpression:@"WHERE testEnumType < ?"
                                                  arguments:@[@(JCTestEnumTypeOne)]];
count = [JCTestRecord countAllRecords];
DELETE statement
BOOL result = [JCTestRecord deleteRecordsWithConditions:@{@"testEnumType":@(JCTestEnumTypeTwo)}];
result = [JCTestRecord deleteRecordsWithConditionalExpression:@"WHERE testEnumType < ?"
                                                    arguments:@[@(JCTestEnumTypeOne)]];
result = [JCTestRecord deleteAllRecords];

CocoaPods

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: [email protected]

License

JCDB is released under the MIT License.

Latest podspec

{
    "name": "JCDB",
    "version": "1.0.1",
    "license": "MIT",
    "summary": "A lightweight iOS database framework based on FMDB and SQLite.",
    "homepage": "https://github.com/imjoych/JCDB",
    "authors": {
        "ChenJianjun": "[email protected]"
    },
    "source": {
        "git": "https://github.com/imjoych/JCDB.git",
        "tag": "1.0.1"
    },
    "source_files": "JCDB/*.{h,m}",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "dependencies": {
        "FMDB": []
    }
}

Pin It on Pinterest

Share This