1.1.4 • Published 2 years ago

@sasaiweb/indexeddb v1.1.4

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

IndexedDB 实践项目

使用方法

安装

npm install git+http://192.168.3.247:3688/tools/project-indexeddb.git#zfeng

使用

<script>
import IndexedDB from 'project-indexeddb'
export default {
    data () {
        return {
          msgStorage: null,
          store: 'store'
        }
    },
    created() {
        this.msgStorage = new IndexedDB();
        this.msgStorage.open('msgDatabase', this.store, 5, 'id', ['time'])// 打开或新建数据库
    },
}
</script>

方法

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
名称      |  说明                |  参数                                                                                                            |  备注
open      |  打开或新建数据库    |  database: 必需,数据库名字;store: 必需,表;version: 可选,数据库版本,默认为1;key:可选,主键,不传自动生成;|  新建数据库后自动新建userId索引
          |                      |  index:可选,索引数组,默认空数组                                                                               |
add       |  添加记录            |  data: 必需,添加的数据                                                                                          |
read      |  主键读取记录        |  key:可选,主键,默许为1;返回读取的数据                                                                        |
update    |  更新记录            |  data: 必需,更新的数据                                                                                          |
remove    |  删除记录            |  key:必需,主键                                                                                                 |
readAll   |  遍历记录            |                                                                                                                  |
findIndex |  索引读取记录        |  index: 必需,索引;value:必需,索引值;返回读取的数据                                                          |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------