Latest 0.2.0
Homepage https://github.com/lzkkk/JLDatabase
License MIT
Platforms ios 8.0, requires ARC
Dependencies FMDB
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

JLDatabase is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'JLDatabase'

LinkDB

example:

NSString *path = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject];

NSString *name = [path stringByAppendingPathComponent:@"test.db"];

[[JLDatabaseManager defaultManager] linkDatabase:name];

create table

conforms to protocol JLDBManagerDelegate, and implement method:

#pragma mark JLDBManageDelegate
//NOT NULL´╝î UNIQUE etc
+ (NSDictionary *)columnExtras{
    return @{@"email":@"NOT NULL",
             @"name":@"NOT NULL"
             };
}

//is blob in db
+ (BOOL)isBlobColumn:(NSString *)name {
    return [name isEqualToString:@"blob"];
}

// ignore key not in column
+ (BOOL)isIgnoreColumn:(NSString *)name {
    return [name isEqualToString:@"ignore"];
}

// primary keys
+ (NSArray *)columnPrimaryKey {
    return @[@"email", @"name"];
}

application

+ (NSArray *)queryAllData {
    return [[JLDatabaseManager defaultManager].database queryTableFromClazz:[JLTestEntity class] where:nil];
}

+ (BOOL)insertTestEntity:(JLTestEntity *)entity{
    return [[JLDatabaseManager defaultManager].database insertTableParameFromArray:@[entity] clazz:[JLTestEntity class] update:YES];
}

+ (BOOL)updateTestEntity:(JLTestEntity *)entity {
    return [[JLDatabaseManager defaultManager].database updateTableParameFromObj:entity where:[NSString stringWithFormat:@"WHERE email=%@ and  name =%@", entity.email, entity.name]];
}

+ (BOOL)deleteTestEntityByEmail:(NSString *)email name:(NSString *)name {
    return [[JLDatabaseManager defaultManager].database deleteTableParameFromClazz:[JLTestEntity class] where:[NSString stringWithFormat:@"WHERE email=%@ and name=%@", email, name]];
}

- (NSString *)description {
    return [NSString stringWithFormat:@"email: %@ n name= %@ n age: %zi n newBee= %zi n blob=%@ n ignore=%@", self.email, self.name, self.age, self.newbee, self.blob, self.ignore];
}

use it is so easy!

Author

lzkkk, [email protected]

License

JLDatabase is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "JLDatabase",
    "version": "0.2.0",
    "summary": "JLDatabase base on FMDB",
    "description": "JLDatabase base on FMDB, use FMDB is easy.",
    "homepage": "https://github.com/lzkkk/JLDatabase",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "lzkkk": "[email protected]"
    },
    "source": {
        "git": "https://github.com/lzkkk/JLDatabase.git",
        "tag": "0.2.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "JLDatabase/Classes/*.{h,m}",
    "requires_arc": true,
    "dependencies": {
        "FMDB": []
    }
}

Pin It on Pinterest

Share This