import Dexie, { Table } from 'dexie' /* * create a database for bucket file cache *database name: bucketFileDb *structure: * - table: picBedName * - key: alias-bucketName-prefix * - value: from fullList * - primaryKey: key */ export interface IFileCache { key: string value: any } /** * new picbed will add a plist suffix to distinguish from picgo */ export class FileCacheDb extends Dexie { aliyun: Table github: Table imgur: Table local: Table tcyun: Table qiniu: Table smms: Table s3plist: Table sftp: Table upyun: Table webdavplist: Table constructor () { super('bucketFileDb') const tableNames = ['aliyun', 'github', 'imgur', 'local', 'qiniu', 's3plist', 'sftp', 'smms', 'tcyun', 'upyun', 'webdavplist'] const tableNamesMap = tableNames.reduce((acc, cur) => { acc[cur] = '&key, value' return acc }, {} as IStringKeyMap) this.version(5).stores(tableNamesMap) this.aliyun = this.table('aliyun') this.github = this.table('github') this.imgur = this.table('imgur') this.local = this.table('local') this.qiniu = this.table('qiniu') this.tcyun = this.table('tcyun') this.s3plist = this.table('s3plist') this.sftp = this.table('sftp') this.smms = this.table('smms') this.upyun = this.table('upyun') this.webdavplist = this.table('webdavplist') } } export const fileCacheDbInstance = new FileCacheDb()