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

dswda

v1.0.57

Published

浏览器端数据存储解决方案。

Readme

dswda

浏览器端数据存储解决方案。

dswda 提供统一 API 来管理多种浏览器存储后端,当前内置 indexeddb 和 localdb,同时支持对象式 CRUD、SQL 中间件、链式 API、自定义 store、插件和 Worker 执行模式。

安装

npm i dswda

如果你要直接写 SQL,再安装:

npm i @dswda/middle-parse-sql

30 秒上手

import { createDB, appStart } from 'dswda';

const app = createDB();
const db = appStart(app);

await db.initDB({
  dname: 'demo',
  version: 1,
  tables: [
    {
      name: 'users',
      primaryKey: 'id',
      auto: true,
      fields: [
        { name: 'id', unique: true, type: 'number' },
        { name: 'name', type: 'string' },
        { name: 'age', type: 'number' }
      ]
    }
  ]
});

await db.insert({
  into: 'users',
  values: [
    { id: 1, name: 'Alice', age: 18 },
    { id: 2, name: 'Bob', age: 20 }
  ]
});

const result = await db.select({
  from: 'users',
  where: [{ age: { attr: '>', value: 18 } }]
});

console.log(result);

SQL 示例

import { createDB, appStart } from 'dswda';
import parseSql from '@dswda/middle-parse-sql';

const app = createDB();
app.addMiddle(parseSql());

const db = appStart(app);

const result = await db.sql(
  "select id, name from users where status in ('active', 'archived')"
);

console.log(result);

核心能力

  • 统一 API:initDB()、createDB()、select()、insert()、update()、del()、sql()
  • 内置后端:indexeddb、localdb
  • 查询能力:where、order、limit、groupBy、having、join
  • 扩展能力:中间件、插件、自定义 store、链式 API。当前内置 @dswda/middle-parse-sql 解析中间件。

返回结果

主要 API 返回统一的 ResultData 结构:

type ResultData<R> = {
  type: 0 | 1 | -1;
  result: R;
};

常见结果类型:

  • 查询:Array<T>
  • 插入:boolean
  • 删除:boolean
  • 更新:Array<T>

SQL 支持范围

当前 SQL parser 支持常见 SQL 子集:

  • SELECT / INSERT / UPDATE / DELETE
  • CREATE / ALTER / RENAME / DROP
  • WHERE / JOIN / ORDER BY / LIMIT
  • GROUP BY / HAVING
  • LIKE / IN / BETWEEN / IS NULL

它的定位是浏览器端对象存储方案,不是通用数据库系统,也不追求完整数据库方言兼容。

仓库

  • 仓库主页:dswda/webdb

文档

请参考项目根目录的完整文档:

许可证

本项目基于 MIT 发布。