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

xdriver

v2.0.21

Published

A simple driver for IndexDB

Readme

说明

初始化Connection

import {KeyRange, Driver} from 'xdriver';
// 初始化数据库驱动
const driver = new Driver('demo', version);
// 定义表结构以及初始化数据
driver.defineTables({
    name: 'player',
    primaryKey: 'id',
    autoIncrement: true,
    indexes: [
        {name: 'age_index', column: 'age'},
        {name: 'name_index', column: 'name'},
        {name: 'double_index', column: ['sex', 'age']},
    ],
    rows: [{name: 'xxx', age: '', sex: ''}] //初始化数据
});
const connect = await driver.connect();

查询操作

const player = connect.table('player');

let results = await player.queryByIndex('age_index', KeyRange.between(10, 20));
results = await player.queryByIndex('double_index', KeyRange.eq(['女3', 0]));
results = await player.query(KeyRange.between(10, 20))
results = connect.queryByIndex('tableName', 'indexName', KeyRange.between(10, 20))

API

Connection

/**
 * 查询数据
 * @param table 表名
 * @param query 查询条件
 * @param count 查询数量
 */
query<R extends Row>(table: string, query?: IDBValidKey | IDBKeyRange, count: number = 1000): Promise<RowPacket<R>>;

/**
 * 查询数据
 * @param table 表名
 * @param key 查询条件
 * @param index 索引名称
 * @param count 查询数量
 */
select<R extends Row>(table: string, key?: IDBValidKey | IDBKeyRange, index?: string, count: number = 1000): Promise<RowPacket<R>>;

/**
 * 获取数据
 * @param table 表名
 * @param key 查询条件
 */
queryByKey<R extends Row>(table: string, key: IDBValidKey | IDBKeyRange): Promise<RowPacket<R>>;

/**
 *
 * @param table
 * @param indexName 索引名称
 * @param key key or keyRange (对应的是索引包含的列的数据)
 * @param count 返回的列数
 */
async queryByIndex<R extends Row>(table: string, indexName: string, key?: IDBValidKey | IDBKeyRange, count?: number): Promise<RowPacket<R>>;

/**
 * 获取数据
 * @param table
 * @param id
 * @param indexName
 */
async queryById<R extends Row>(table: string, id: any | Array<any>, indexName?: string): Promise<R>;

/**
 * 获取数据
 * @param table 表名
 * @param key 查询条件
 */
count(table: string, key: IDBValidKey | IDBKeyRange);

/**
 * 插入数据
 * @param table
 * @param data
 */
insert(table: string, data: Array<Record<string, any>>);

/**
 * 更新数据
 * @param table 表名
 * @param modify 更新内容
 * @param key 条件
 */
update(table: string, modify: Row, key?: IDBValidKey | IDBKeyRange | null);

/**
 * 删除数据
 * @param table 表名
 * @param key 索引名称
 */
delete(table: string, key: IDBValidKey | IDBKeyRange);

/**
 * 清空表
 * @param table 表名
 */
truncate(table: string);

/**
 * 获取内存分页模型对象
 * @param table
 * @param pageSize
 */
getPagination<R extends Row>(table: string, pageSize: number = 10): Promise<Pagination<R>>;

/**
 * 扫描数据
 * @param table 表名
 * @param key key or keyRange (对应的是主键的数据)
 * @param direction 游标方向
 * @param indexName 索引名称
 */
async scan<R extends Row>(table: string, key?: IDBValidKey | IDBKeyRange, direction: IDBCursorDirection = 'next', indexName?: string): Promise<RowPacket<R>>;

/**
 * 获取所有数据
 * @param table
 */
getAllData<R extends Row>(table: string): Promise<Array<R>>;

/**
 * 分页查询
 * @param table
 * @param pageNo 页码
 * @param pageSize 每页数量
 * @param key (对应的是主键的数据)
 * @param indexName 索引名称
 */
async paginate<R extends Row>(table: string, pageNo: number = 1, pageSize: number = 10, key?: IDBValidKey | IDBKeyRange, indexName?: string): Promise<RowPacket<R>>;