1.0.1 • Published 2 years ago

kh-no-sql v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

kh-event-bus

简介: 前端非关系型数据库,key-value形式的数据库

Installing

Using npm:

$ npm install kh-no-sql

Using yarn:

$ yarn add kh-no-sql

Example

import IndexedDB from 'kh-no-sql'

// 1、创建数据库连接并创建表
const db = IndexedDB('test',1,'table1','id','name','age')
// 参数说明:数据库名称、版本、表名、表字段(后面的为剩余参数)
// 注意:这里以表字段的第一个字段作为key,使用时切记

// 2、插入一条数据
db.insertData('table1',{id:1,name:'test',age:26},(res:any)=>console.log(res),(res:any)=>console.log(res))
// 参数说明:表名、数据对象、成功回调函数(可选)、失败回调函数(可选)

// 3、删除一条数据
db.deleteData('table1',1,(res:any)=>console.log(res),(res:any)=>console.log(res))
// 参数说明:表名、key、成功回调函数、失败回调函数

// 4、修改一条数据
db.updateData('table1',{id:1,name:'test',age:20},(res:any)=>console.log(res),(res:any)=>console.log(res))
// 参数说明:表名、修改的数据对象(注意必须包含key,若key存在数据库中则修改,否则为新增)、成功回调函数、失败回调函数

// 5、读取数据
db.readData('table1',1,(res:any)=>console.log(res),(res:any)=>console.log(res))
// 参数说明:表名、key、成功回调函数、失败回调函数

// 6、删除数据库
db.deleteDatabase('test',(res:any)=>console.log(res),(res:any)=>console.log(res))
// 参数说明:数据库名、成功回调函数、失败回调函数

// 7、关闭数据库连接
db.closeDatabase()
1.0.1

2 years ago

1.0.0

2 years ago