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

@adens_w/indexeddb

v1.1.2

Published

promise-based indexeddb

Readme

indexedDB

javascript promise-based indexedDB

简介

基本的增(add)删(delete)改(put)查(get)的功能

不用关心IndexedDB的version问题.

使用

默认会创建有一个配置库,用来管理所有的database的version.

首次创建数据库是会默认创建配置库,也可调用initialize手动创建,但是不推荐使用.

配置库名:"aidb_default",有一张配置表:"aidb_params".

会保存所有使用aidb创建的数据库,用来管理数据库的version.而不用手动管理.

如果在使用aidb前就创建过数据库,可以直接在配置表中新增记录,加入到aidb的管理

createTable


aidb().open("DB_TestDB").createTable("mainTable",{keyPath: 'id'},{key:"subId",unique:true}).execude().then(()=>{
    console.log("success")
}).catch(()=>{
    console.log("error")
})

open(database,version) 打开数据库,如果不存在会自动创建.接受两个字段database,version.一般不建议传入version,数据库version会自动从配置里读取.不用手动维护了

createTable(tablename,keypath,index)接受三个参数,1.表名,2.主键,3.索引({key:索引字段,unique:是否唯一})

所有的操作只有在执行execude()之后才会保存到数据库.并且返回一个Promise对象.

add

新增单个

    aidb().open("DB_TestDB").add("mainTable",
        {
            id:"1",
            subId:"1",
            params:{
                param1:"params1",
                param2:"params2",
                },
            arr:[1,2,3,4]
        }).execude()

新增多个

aidb().open("DB_TestDB").add("mainTable",
    [{
        id:"2",
        subId:"2",
        params:{
            param1:"params1",
            param2:"params2",
        },
        arr:[1,2,3,4]
    },
    {
        id:"3",
        subId:"3",
        params:{
            param1:"params1",
            param2:"params2",
        },
        arr:[1,2,3,4]
    }
]).execude()

也可以分开写

aidb().open("DB_TestDB").add("mainTable",
    {
        id:"2",
        subId:"2",
        params:{
            param1:"params1",
            param2:"params2",
        },
        arr:[1,2,3,4]
    }
).add("mainTable",
    {
        id:"3",
        subId:"3",
        params:{
            param1:"params1",
            param2:"params2",
        },
        arr:[1,2,3,4]
    }
).execude()

put

aidb().open("DB_TestDB").put("mainTable", { id:"2", subId:"2", params:{ param1:"params1", param2:"params2", }, arr:[1,2,3,4].reverse(); } ).execude()

delete

aidb().open("DB_TestDB").delete("mainTable", { id:"2", subId:"2", params:{ param1:"params1", param2:"params2", }, arr:[1,2,3,4].reverse(); } ).execude()

get

获取单个

aidb().open("DB_TestDB").get("mainTable",1).then((result)={
    console.log(result)
})

获取多个

aidb().open("DB_TestDB").get("mainTable",[1,2,4,5]).then((result)={
    console.log(result)
})

带条件查询 获取subId字段为1,2,3,4的值,等同于getQuery("mainTable",{"subId":[1,2,4,5]})

aidb().open("DB_TestDB").get("mainTable",{"subId":[1,2,4,5]}).then((result)={
    console.log(result)
})

索引查询,区别于上一个语句.由于IndexedDB的api局限性.subId是单一的值,而不是一个数组.且只传入单一的index.

aidb().open("DB_TestDB").get("mainTable",{"subId":1}).then((result)={
    console.log(result)
})

多条件查询 获取id为1且subId字段为1,2,3,4的值等同于getQuery("mainTable",{"id":"1","subId":[1,2,4,5]})

aidb().open("DB_TestDB").get("mainTable",{"id":"1","subId":[1,2,4,5]}).then((result)={
    console.log(result)
})

条件查询(可查询非索引字段.开销较大)

aidb().open("DB_TestDB").getQuery("mainTable",{ params:{
            param1:"params1",
            param2:"params2",
        },"subId":[1,2,4,5]}).then((result)={
    console.log(result)
})

获取全部

aidb().open("DB_TestDB").getAll("mainTable").then((result)={
    console.log(result)
})