MITDB

介绍
- MITDB 再次是 FMDB 封装,增加了 ORM、数据库迁移和数据库加密功能。
- MITDB 适用于面向对象的数据库操作模式
- MITDB 使用名为 MitDBProtocol 的协议在不侵扰模型的情况下添加功能。
- MITDB 增加了链式编程以创建数据更新和查询功能。
- MITDB 使用 MitDBMigrationHandle 和 MitDBMigration 执行数据库迁移功能。
- MITDB 使用 MitFMEncryptDatabase 和 MitFMEncryptDatabaseQueue 添加数据库加密功能。
- MITDB 使用 NSObject+MitDBHandle 执行 IDUS 操作。
将 MITDB 集成到您的项目中
pod 'MITDB'
如何使用 MITDB
//Your model
#import <Foundation/Foundation.h>
#import <MITDB/MitDBProtocol.h>
@interface MITDBTestModel : NSObject<MitDBProtocol>
@property(nonatomic, strong)NSString * name;
@property(nonatomic, assign)NSInteger age;
@property(nonatomic, strong)NSString * email;
@property(nonatomic, strong)NSString * psd;
@property(nonatomic, strong)NSString * uid;
@end
#import "MITDBTestModel.h"
@implementation MITDBTestModel
@end
//Insert
MITDBTestModel * mol = [MITDBTestModel new];
mol.name = @"save";
[mol save];
//Update
mol.name = @"update";
[mol update];
//Delete
[mol remove];
//Select
[MITDBTestModel selectAllCompletion:^(NSArray *arr) {
NSLog(@"%@",arr);
}];
+ (NSString *)primaryKey{
return @"uid";
}
+ (NSArray *)ignoreKeys{
return @[@"name",@"age"];
}
- 使用 MitDBParam 将查询字符串拼接在一起。
MitDBParam * pa =[MitDBParam new];
pa.where(@"name").equal(@"a").AND().propertyName(@"email").equal(@"[email protected]");
[MITDBTestModel selectWithParam:pa completion:^(NSArray *arr) {
//result
}];
介绍
- MITDB 是对 FMDB 的二次封装,添加了 ORM 功能,数据库迁移功能和数据库加密功能。
- MITDB 用于面向对象模型的数据库操作。
- MITDB 通过 MitDBProtocol 轻量级的协议引用方式到模型中,无侵染性。
- MITDB 通过 MitDBParam 增加了链式编程创建数据的更新与查询语句。
- MITDB 通过 MitDBMigrationHandle 与 MitDBMigration 类来添加数据库迁移功能。
- MITDB 通过 MitFMEncryptDatabase 与 MitFMEncryptDatabaseQueue 来添加数据库加密功能。
- MITDB 通过 NSObject+MitDBHandle 类来进行增删改查的操作。
集成 MITDB
pod 'MITDB'
使用 MITDB
//自定义模型
#import <Foundation/Foundation.h>
#import <MITDB/MitDBProtocol.h>
@interface MITDBTestModel : NSObject<MitDBProtocol>
@property(nonatomic, strong)NSString * name;
@property(nonatomic, assign)NSInteger age;
@property(nonatomic, strong)NSString * email;
@property(nonatomic, strong)NSString * psd;
@property(nonatomic, strong)NSString * uid;
@end
#import "MITDBTestModel.h"
@implementation MITDBTestModel
@end
//增加
MITDBTestModel * mol = [MITDBTestModel new];
mol.name = @"save";
[mol save];
//更新
mol.name = @"update";
[mol update];
//删除
[mol remove];
//查询
[MITDBTestModel selectAllCompletion:^(NSArray *arr) {
NSLog(@"%@",arr);
}];
+ (NSString *)primaryKey{
return @"uid";
}
+ (NSArray *)ignoreKeys{
return @[@"name",@"age"];
}
MitDBParam * pa =[MitDBParam new];
pa.where(@"name").equal(@"a").AND().propertyName(@"email").equal(@"[email protected]");
[MITDBTestModel selectWithParam:pa completion:^(NSArray *arr) {
//查询结果
}];