@kuiu/indexed-db

1.0.0 • Public • Published

indexedDB

支持功能

  1. 动态创建数据表
  2. 最大存储数据量
  3. 支持数据过期
  4. 支持添加,批量添加,按条件查询,删除,批量删除, 更新,批量更新
  5. 支持导出数据

demo

import indexedDB from '@kui/indexedDB';
const instance = new indexedDB('dbName', {
    maxAge: 10, // 默认保存10天,
    maxLength: 1000, // 默认每个数据表保存1000 条数据
    tables: {
        // 表结构
        tableName: {
            keyPath: "$id", // 默认主键
            autoIncrement: true, // 自增
            indexNames: {
                // 索引
                indexName: true
            }
        }
    }
})
instance.add('tableName', data, {
    multi: false,
    ...tableConfig
}) => Promise

instance.query('tableName', {
    value: any,
    indexName: string | null,
    count: number;
    keyRange: IDBKeyRange,
    direction: IDBCursorDirection
}) => Promise
instance.delete('tableName', {
    value: any,
    indexName: string | null,
    count: number;
    keyRange: IDBKeyRange,
    direction: IDBCursorDirection
}) => Promise
instance.update('tableName', {
    value: any,
    indexName: string | null,
    count: number;
    keyRange: IDBKeyRange,
    direction: IDBCursorDirection
}) => Promise
// 导出
instance.export('tableName')

todo

  1. 内置config 表数据

Package Sidebar

Install

npm i @kuiu/indexed-db

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

455 kB

Total Files

11

Last publish

Collaborators

  • tobog