Latest 1.0.1
Homepage https://github.com/leszek-s/LSMiniDB
License MIT
Platforms ios 7.0, tvos 9.0, requires ARC

LSMiniDB is a simple to use and minimalistic database. Easy to configure from code. All database operations (insert/select/update/delete) are performed with NSDictionary objects asynchronously on a background thread.

Configuring database model and storage

- (void)configureDatabase
{
    NSDictionary *userTable = @{ @"uuid" : @(NSStringAttributeType),
                                 @"name" : @(NSStringAttributeType),
                                 @"score" : @(NSInteger32AttributeType),
                                 @"date" : @(NSDateAttributeType) };

    NSDictionary *eventTable = @{ @"name" : @(NSStringAttributeType),
                                  @"date" : @(NSDateAttributeType) };

    NSDictionary *model = @{ @"user" : userTable,
                             @"event" : eventTable };

    [[LSMiniDB defaultInstance] configureWithModel:model fileName:@"database.db"];
}

Usage examples

NSDictionary *user = @{ @"uuid" : [NSUUID UUID].UUIDString,
                        @"name" : @"John",
                        @"score" : @55,
                        @"date" : [NSDate new] };

// insert
[[LSMiniDB defaultInstance] insertObject:user table:@"user" completion:^{
    NSLog(@"inserted user");
}];

// select
[[LSMiniDB defaultInstance] selectObjectsFromTable:@"user" predicate:[NSPredicate predicateWithFormat:@"name == %@", @"John"] sortDescriptors:@[[NSSortDescriptor sortDescriptorWithKey:@"score" ascending:NO]] limit:5 completion:^(NSArray<NSDictionary *> *objects) {
    NSLog(@"selected users");
}];

// update
[[LSMiniDB defaultInstance] updateObject:user table:@"user" predicate:[NSPredicate predicateWithFormat:@"uuid == %@", user[@"uuid"]] completion:^{
    NSLog(@"updated user");
}];

// delete
[[LSMiniDB defaultInstance] deleteObjectsFromTable:@"user" predicate:[NSPredicate predicateWithFormat:@"uuid == %@", user[@"uuid"]] completion:^{
    NSLog(@"deleted user");
}];

More examples in sample project.

License

LSMiniDB is available under the MIT license.

Latest podspec

{
    "name": "LSMiniDB",
    "version": "1.0.1",
    "summary": "Simple and minimalistic database",
    "homepage": "https://github.com/leszek-s/LSMiniDB",
    "license": "MIT",
    "authors": "Leszek S",
    "source": {
        "git": "https://github.com/leszek-s/LSMiniDB.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "7.0",
        "tvos": "9.0"
    },
    "source_files": "LSMiniDB",
    "requires_arc": true
}

Pin It on Pinterest

Share This