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 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsdb-tool

v3.0.3

Published

js indexdb封装库

Downloads

176

Readme

jsdb-tool插件使用说明

本插件是wz-js-db得增强,wz-js-db后续不在维护,使用wz-js-db项目可以切换至jsdb-tool

import { BaseUtil, Table, PrimaryKey, IndexKey, CreateTime, UpdateTime, Storage } from "jsdb-tool";

// Storage为BaseUtil的同步实现,使用方式同BaseUtil,但不支持mode为db的情况

@Table({
    databaseName: "test", // 数据库名称
    tableName: "log", // 表名
    version: 1, // 当前版本号
    mode: "db", // 数据库类型 'db' | 'localStorage' | 'sessionStorage'
})
class LogDb extends BaseUtil {
    
    // 构造函数优先
    constructor({
        databaseName: "test", // 数据库名称
        tableName: "log", // 表名
        version: 1, // 当前版本号
        mode: "db", // 数据库类型 'db' | 'localStorage' | 'sessionStorage'
    }) {

    }

    // 主键
    @PrimaryKey()
    id;

    // 索引
    @IndexKey()
    dateTime;

    // 数据插入时间
    @CreateTime()
    createTime;

    // 数据更新时间
    @UpdateTime()
    updateTime;
}

// 实例化数据库, 实例所有方法均返回promise
const db = new LogDb()



//新增数据 flag 是否存在更新不存在则新增
dn.insert(data: any, flag = true) 

// 修改数据
dn.update(data: any)

// 删除当前表
dn.destroy(key: IDBValidKey | IDBKeyRange)

//清空当前表
dn.clear()

// 查询当前表数据总数
dn.count()

// 根据主键删除当前表数据 key -  主键
dn.delete(key)

//根据索引删除数据 index -  索引, val索引对应的值
dn.deleteByIndex(index: string, val: IDBValidKey | IDBKeyRange = '')

//根据主键查询当前表数据 key -  主键或索引键  
dn.findById(key: IDBValidKey | IDBKeyRange)

//根据索引查询当前表数据 index -  索引, val索引对应的值
dn.findByIndex(index: string, val: IDBValidKey | IDBKeyRange = '')

// 查询当前表所有数据
dn.findAll()

// 分页查询数据 current -  当前页 size - 每页条数
dn.selectPage(current?: number = 1, size?: number = 10)