ciqtek-db

ciqtek index-db

Usage no npm install needed!

<script type="module">
  import ciqtekDb from 'https://cdn.skypack.dev/ciqtek-db';
</script>

README

ciqtek-db

一个基于indexDB的数据持久化解决方案。

安装

npm install ciqtek-db

or

yarn add ciqtek-store

使用


import DB from 'ciqtek-db'
const db = new DB({
  name: "baseSource",
  version: 1,
  storeName:"base"
})

API


/**
 * 创建数据库
 * @param {string| Array<string>} sourceName 资源名称
 */
addSource(sourceName: string | Array<string>)


/**
 * 更新字段
 * @param {string} currentSource 表字段
 * @param {string} key 数据key
 * @param {any} data 更新数据
 */ 
updateItem (currentSource: string, key: string,data:any)


/**
 * 数据get
 * @param {string} currentSource 表字段
 * @param {string} key 数据key
 * @returns {Promise} any 数据
 */ 
getItem(currentSource: string, key: string): Promise<any>


/**
 * 数据set
 * @param {string} currentSource 表字段
 * @param {string} key 数据key
 * @param {any} data 更新数据
 * @returns {Promise} any 数据
 */  
setItem(currentSource: string, key: string, value: any): Promise<any>


/**
 * 数据remove
 * @param {string} currentSource 表字段
 * @param {string} key 数据key
 * @returns {Promise} any 数据
 */  
removeItem(currentSource: string, key: string): Promise<any> 


/**
 * 清空数据
 */   
clearOrgin()