zoukankan      html  css  js  c++  java
  • 数据库键-值方式存储封装

    //
    //  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

  • 相关阅读:
    Docker安装nexus
    docker常用操作备忘
    react-01
    SBT实操指南
    Play中JSON序列化
    SPARK安装一:Windows下VirtualBox安装CentOS
    SPARK安装三:SPARK集群部署
    SPARK安装二:HADOOP集群部署
    SLICK基础
    函数式编程
  • 原文地址:https://www.cnblogs.com/hxwj/p/4635770.html
Copyright © 2011-2022 走看看