Latest 0.0.6
Homepage https://github.com/greedlab/GreedDB
License MIT
Platforms ios 6.0, requires ARC
Dependencies FMDB, GreedJSON
Frameworks Foundation
Authors

GreedDB Join the chat at https://gitter.im/greedlab/GreedDB Build Status

A storage for ios. based on FMDB and GreedJSON. can save NSDictionary,NSArray,NSData,NSString,NSNumber or NSObject directly

Installation

pod ‘GreedDB’

Usage

GRDatabaseDefaultQueue

storage for the model GRDatabaseDefaultModel

- (void)initDefault
{
    self.database = [[GRDatabaseDefaultQueue alloc] init];
    NSLog(@"%@",_database.dbPath);

    [_database setTableName:@"testDefault"];
    [_database setCreateFilterIndex:YES];
    [_database setCreateKeyIndex:YES];
    [_database setCreateSortIndex:YES];

    [_database recreateTable];
}

- (void)saveDefault
{
    GRTestDefaultModel *model = [[GRTestDefaultModel alloc] init];
    model.string = @"string";
    model.integer =  1;
    NSString *filter = [GRTestDefaultModel filterForFilter1:@"filter1" filter2:@"filter1"];

    GRDatabaseDefaultModel *dbModel = [[GRDatabaseDefaultModel alloc] init];
    [dbModel setKey:@1];
    [dbModel setValue:model];
    [dbModel setFilter:filter];

    [_database saveWithModel:dbModel];
}

- (void)updateDefault
{
    NSString *filter = [GRTestDefaultModel filterForFilter1:@"filter1" filter2:@"filter1"];

    GRTestDefaultModel *model = [[GRTestDefaultModel alloc] init];
    model.string = @"update";
    model.integer =  2;

    [_database updateValue:model byKey:@1 filter:filter];
}

- (void)getDefault
{
    NSString *filter = [GRTestDefaultModel filterForFilter1:@"filter1" filter2:@"filter1"];

    NSArray *array = [_database getValuesByKey:@1 filter:filter];

    NSLog(@"%@",array);
}

GRDatabaseMultFilterQueue

used for getting value from mult filters. eg :search with more keys

- (void)initMultFilter
{
    self.multFilterQueue = [[GRDatabaseMultFilterQueue alloc] init];
    NSLog(@"%@",_multFilterQueue.dbPath);
    [_multFilterQueue setValueName:[GRTestMultFilterModel valueName]];
    [_multFilterQueue setFilterNames:[GRTestMultFilterModel filterNames]];
    [_multFilterQueue setTableName:@"testMultFilter"];
    [_multFilterQueue recreateTable];
}

- (void)saveMultFilter
{
    GRTestMultFilterModel *model = [[GRTestMultFilterModel alloc] init];
    model.value = @"value";
    model.filter1 = @"filter1";
    model.filter4 = @"filter4";

    [_multFilterQueue saveWithValueFiltersDictionary:[model gr_dictionary]];
}

- (void)getMultFilter
{
    GRTestMultFilterModel *model = [[GRTestMultFilterModel alloc] init];
    model.filter1 = @"filter1";
    model.filter4 = @"filter4";
    NSArray *array = [_multFilterQueue getValuesByFiltersDictionary:[model gr_noNUllDictionary]];
    NSLog(@"%@",array);
}

- (void)delMultFilter
{
    GRTestMultFilterModel *model = [[GRTestMultFilterModel alloc] init];
    model.filter1 = @"filter1";
    model.filter4 = @"filter4";

    [_multFilterQueue delByValueFiltersDictionary:[model gr_noNUllDictionary]];
}

Release Notes

  • 0.0.1 first version
  • 0.0.2 add limit to GRDatabaseDefaultQueue
  • 0.0.3 replace MJExtension with GreedJSON
  • 0.0.5 whether create index is customed now
  • 0.0.6 add some methods to GRDatabaseDefaultQueue

LICENSE

MIT

Latest podspec

{
    "name": "GreedDB",
    "version": "0.0.6",
    "summary": "convenient storage for ios",
    "description": "this is a storage manager for ios. based on FMDB and GreedJSON. can save NSDictionary,NSArray,NSData,NSString,NSNumber or NSObject  directly",
    "homepage": "https://github.com/greedlab/GreedDB",
    "license": "MIT",
    "authors": {
        "Bell": "[email protected]"
    },
    "platforms": {
        "ios": "6.0"
    },
    "source": {
        "git": "https://github.com/greedlab/GreedDB.git",
        "tag": "0.0.6"
    },
    "source_files": [
        "GreedDB",
        "GreedDB/*.{h,m}"
    ],
    "frameworks": "Foundation",
    "requires_arc": true,
    "dependencies": {
        "FMDB": [],
        "GreedJSON": []
    }
}

Pin It on Pinterest

Share This