npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

webindexeddb

v1.0.1

Published

indexeddb封装,简单查询,可用于前端mock数据

Readme

webindexeddb

展示图

  • 持久化模拟数据库对象存储,可配合mockjs实现大数据量的数据模拟,可以解决storage可用存储空间小的问题,可以保存图片数据
  • 当前版本:v1.0.0

安装方式

  1. npm/yarn方式安装
npm install webindexeddb --save
or  
yarn add webindexeddb  
  1. cdn方式
<script src="https://cdn.jsdelivr.net/gh/yinyangshibolange/webindexeddb/lib/bundle.umd.min.js"></script>  

demo

demo仓库地址:https://github.com/yinyangshibolange/webindexeddb

在线预览地址:https://yinyangshibolange.github.io/webindexeddb/demo.html

IndexdbStore配置项

| key | type(类型) | Description(描述) | Default(默认) | |---------|----------|-----------------|-----------------| | name | String | 数据库名称 | 'indexeddbname' | | version | Number | 数据库版本 | 1 | | stores | Array | 数据库表初始化配置 | [] |

stores表配置

| key | type(类型) | Description(描述) | Default(默认) | |---------|----------|-----------------|-------------| | storeName | String | 表名 | '' | | mainKey | String | 主键 | 'id' | | indexs | Array | 索引配置 | [] |

indexs索引配置

| key | type(类型) | Description(描述) | Default(默认) | |---------|----------|-----------------------|-------------| | name | String | 索引名 | '' | | keyPath | String | 索引字段,多个字段用","分割 | '' | | params | Object | 索引配置,可设置索引类型,例如unique | {} |

使用方法

  1. 在html原生js使用方式
<script src="https://cdn.jsdelivr.net/gh/yinyangshibolange/webindexeddb/lib/bundle.umd.min.js"></script>
<body>
<div id="ctx_menu"></div>
</body>
<script>
    var indexedStore = new window.IndexdbStore({
        name: "myindexdb", // 你的indexdb数据库名称
        version: 7, // 如果修改了options里的stores参数,那么必须修改version版本号,不然stores的修改不会生效
        stores: [
            { // 类似数据库表
                storeName: "demoStore",
                // mainKey: 'id', // 主键,默认为id
                // indexs: []
            },
            { // 类似数据库表
                storeName: "imageList",
                // mainKey: 'id', // 主键,默认为id
                indexs: [{
                    name: "parentid", // 索引名称
                    keyPath: "parentid", // 索引字段
                    params: {
                        unique: false,
                    }
                }]
            }
        ]
    })

</script> 
  1. 模块化导入方式
import IndexdbStore from "webindexeddb"
const indexedStore = new IndexdbStore({
    name: "myindexdb", // 你的indexdb数据库名称
    version: 7, // 如果修改了options里的stores参数,那么必须修改version版本号,不然stores的修改不会生效
    stores: [
        { // 类似数据库表
            storeName: "demoStore",
            // mainKey: 'id', // 主键,默认为id
            // indexs: []
        },
        { // 类似数据库表
            storeName: "imageList",
            // mainKey: 'id', // 主键,默认为id
            indexs: [{
                name: "parentid", // 索引名称
                keyPath: "parentid", // 索引字段
                params: {
                    unique: false,
                }
            }]
        }
    ]
})

IndexdbStore对象包含4个属性

  • name
  • version
  • stores

上面3个属性已在上方列出

  • db (IndexedDB对象,无需使用)

IndexdbStore对象包含10个数据库操作函数

| functionName | desciption(描述) | params(参数) | |--------------|------------------------------------------------------------------|--------------------------------------------------------| | addItem | 新增数据,自动添加addtime和addtimeformat字段,会自动添加[mainKey](主键)字段 | storeName, data | | addBatch | 批量新增数据,自动添加addtime和addtimeformat字段,会自动添加[mainKey](主键)字段 | storeName, list | | updateItem | 修改数据,会自动添加updatetime和updatetimeformat | storeName, data | | updateBatch | 批量修改数据,会自动添加updatetime和updatetimeformat | storeName, list | | delItem | 删除数据,id是主键值,不一定是id | storeName, id | ' | delBatch | 批量删除数据,id是主键值,不一定是id | storeName, ids | | getAll | 查询表中所有数据 | storeName, sortParams = [] | | queryAll | 条件查询数据 | storeName, params, sortParams = [] | | queryPage | 条件查询分页数据 | storeName, params, sortParams, page = 1, pagesize = 10 | | rebuild | 数据库动态升级重构,当name,version,stores修改后调用,options同构造函数参数,但可为空,默认使用当前参数 | options |

代码打包工具rollup