数据库键-值方式存储封装
2015-07-10 15:02
323 查看
//
// YTKKeyValueStore.h
// Ape
//
// Created by TangQiao on 12-11-6.
// Copyright (c) 2012年 TangQiao. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface YTKKeyValueItem : NSObject
@property (strong, nonatomic) NSString *itemId;
@property (strong, nonatomic) id itemObject;
@property (strong, nonatomic) NSDate *createdTime;
@end
@interface YTKKeyValueStore : NSObject
/**
* 打开数据库不存在在沙盒中创建
*
* @param dbName 数据库的名字test.db
*
*/
- (id)initDBWithName:(NSString *)dbName;
/**
* 工程路径打开数据库
*
* @param dbPath 工程路径
*
*/
- (id)initWithDBWithPath:(NSString *)dbPath;
/**
* 创建表
*
* @param tableName 表的名字
*/
- (void)createTableWithName:(NSString *)tableName;
- (BOOL)isTableExists:(NSString *)tableName;
/**
* 清除表
*/
- (void)clearTable:(NSString *)tableName;
/**
* 关闭数据库
*/
- (void)close;
///************************ Put&Get methods *****************************************
//存入(NSString, NSNumber, NSDictionary和NSArray)修改和添加
- (void)putString:(NSString *)string withId:(NSString *)stringId intoTable:(NSString *)tableName;
- (void)putObject:(id)object withId:(NSString *)objectId intoTable:(NSString *)tableName;
- (void)putNumber:(NSNumber *)number withId:(NSString *)numberId intoTable:(NSString *)tableName;
//取出 (NSString, NSNumber, NSDictionary和NSArray)
- (id)getObjectById:(NSString *)objectId fromTable:(NSString *)tableName;
- (NSString *)getStringById:(NSString *)stringId fromTable:(NSString *)tableName;
- (NSNumber *)getNumberById:(NSString *)numberId fromTable:(NSString *)tableName;
//删除
- (void)deleteObjectById:(NSString *)objectId fromTable:(NSString *)tableName;
- (void)deleteObjectsByIdArray:(NSArray *)objectIdArray fromTable:(NSString *)tableName;
- (void)deleteObjectsByIdPrefix:(NSString *)objectIdPrefix fromTable:(NSString *)tableName;
//更多接口
- (YTKKeyValueItem *)getYTKKeyValueItemById:(NSString *)objectId fromTable:(NSString *)tableName;
//获得所有数据
- (NSArray *)getAllItemsFromTable:(NSString *)tableName;
//数量
- (NSUInteger)getCountFromTable:(NSString *)tableName;
@end
github链接:https://github.com/yuantiku/YTKKeyValueStore
百度云盘:http://pan.baidu.com/s/1jG9w6EU
// YTKKeyValueStore.h
// Ape
//
// Created by TangQiao on 12-11-6.
// Copyright (c) 2012年 TangQiao. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface YTKKeyValueItem : NSObject
@property (strong, nonatomic) NSString *itemId;
@property (strong, nonatomic) id itemObject;
@property (strong, nonatomic) NSDate *createdTime;
@end
@interface YTKKeyValueStore : NSObject
/**
* 打开数据库不存在在沙盒中创建
*
* @param dbName 数据库的名字test.db
*
*/
- (id)initDBWithName:(NSString *)dbName;
/**
* 工程路径打开数据库
*
* @param dbPath 工程路径
*
*/
- (id)initWithDBWithPath:(NSString *)dbPath;
/**
* 创建表
*
* @param tableName 表的名字
*/
- (void)createTableWithName:(NSString *)tableName;
- (BOOL)isTableExists:(NSString *)tableName;
/**
* 清除表
*/
- (void)clearTable:(NSString *)tableName;
/**
* 关闭数据库
*/
- (void)close;
///************************ Put&Get methods *****************************************
//存入(NSString, NSNumber, NSDictionary和NSArray)修改和添加
- (void)putString:(NSString *)string withId:(NSString *)stringId intoTable:(NSString *)tableName;
- (void)putObject:(id)object withId:(NSString *)objectId intoTable:(NSString *)tableName;
- (void)putNumber:(NSNumber *)number withId:(NSString *)numberId intoTable:(NSString *)tableName;
//取出 (NSString, NSNumber, NSDictionary和NSArray)
- (id)getObjectById:(NSString *)objectId fromTable:(NSString *)tableName;
- (NSString *)getStringById:(NSString *)stringId fromTable:(NSString *)tableName;
- (NSNumber *)getNumberById:(NSString *)numberId fromTable:(NSString *)tableName;
//删除
- (void)deleteObjectById:(NSString *)objectId fromTable:(NSString *)tableName;
- (void)deleteObjectsByIdArray:(NSArray *)objectIdArray fromTable:(NSString *)tableName;
- (void)deleteObjectsByIdPrefix:(NSString *)objectIdPrefix fromTable:(NSString *)tableName;
//更多接口
- (YTKKeyValueItem *)getYTKKeyValueItemById:(NSString *)objectId fromTable:(NSString *)tableName;
//获得所有数据
- (NSArray *)getAllItemsFromTable:(NSString *)tableName;
//数量
- (NSUInteger)getCountFromTable:(NSString *)tableName;
@end
github链接:https://github.com/yuantiku/YTKKeyValueStore
百度云盘:http://pan.baidu.com/s/1jG9w6EU
相关文章推荐
- 不安装oracle客户端,用plsql连接oracle
- cxf webservice执行数据库操作
- SQL语句实现模糊查询
- mongodb进阶三之mongodb管理
- SQLAlchemy 多数据源 多个数据库
- mysql必知必会(三)
- MySQL event execution failed
- oracle-创建JOB
- An Overview of Oracle Business Intelligence Apps.
- MySQL数据库用户创建
- Python导入oracle数据的方法
- mysql 内置方法
- redis学习(-) 单节点编译安装
- MySQL安装文档
- mysql查找表名
- ORACLE创建定时任务
- 通过注释查找mysql的表名
- 轻量级开源内存数据库SQLite性能测试
- oracle“记录被另一个用户锁住”
- Oracle VM VirtualBox 实现文件共享 不用重新挂载