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')