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

@feedoom/dbstorage

v0.0.5

Published

simple indexDB

Downloads

8

Readme

storage-db

精简版indexDB,简易移动端使用。

storage-db 添加亿点功能

安装

npm install @feedoom/dbstorage

引入

import StorageDB from '@feedoom/dbstorage';

默认不做任何编译处理

如需编译处理过的js

import StorageDB from '@feedoom/dbstorage/lib/storage';

Promise需自行引入polyfill

初始化

/**
 * @param {dbName} string 数据库名称
 * @param {storeName} string store 名称
 * @param {version} number 数据库版本号
 * @description 初始化indexDB
 */

// 不传参数,默认数据库名 baseDB, 默认store为baseStore, 默认版本为1
const dbstorage = new StroageDB(dbName, store, version);

存储/更新

/**
 * @param {key} string
 * @param {value} any
 * @description 插入数据
 */

dbstorage.setItem('author', 'weyos').then(() => {
  // do something
});

取值

/**
 * @param {key} string
 * @description 获取数据
 */
dbstorage.getItem('author').then((result) => {
  // do something
});

获取所有key

/**
 * @description 获取所有key
 */
dbstorage.keys().then((result) => {
  // do something
});

获取所有数据

/**
 * @description 获取所有数据
 */
dbstorage.values().then((result) => {
  // do something
});

关闭数据库连接

/**
 * @description 关闭数据库连接
 */
dbstorage.closeDB()

// 同一个数据库建立多个store,需关闭除此之外所有数据库的连接
const store1 = new StroageDB('db', 'store1')
await store1.setItem(age, 1)
await store1.closeDB()
const store2 = new StroageDB('db', 'store2')
await store2.setItem(age, 2)

删除某条数据

/**
 * @param {key} string
 * @description 删除数据
 */
dbstorage.removeItem('author').then(() => {
  // do something
});

删除所有数据

/**
 * @description 删除所有数据
 */
dbstorage.clear().then(() => {
  // do something
});

删除store

/**
 * @param {storeName} string
 * @description 删除store
 */
dbstorage.removeStore(storeName).then(() => {
  // do something
});

删除数据库

/**
 * @param {dbName} string
 * @description 删除数据库
 */

dbstorage.removeDB('author');