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 { tcyun: Table aliyun: Table qiniu: Table github: Table smms: Table upyun: Table imgur: Table s3plist: Table webdavplist: Table constructor () { super('bucketFileDb') const tableNames = ['tcyun', 'aliyun', 'qiniu', 'github', 'smms', 'upyun', 'imgur', 's3plist', 'webdavplist'] const tableNamesMap = tableNames.reduce((acc, cur) => { acc[cur] = '&key, value' return acc }, {} as IStringKeyMap) this.version(2).stores(tableNamesMap) this.tcyun = this.table('tcyun') this.aliyun = this.table('aliyun') this.qiniu = this.table('qiniu') this.github = this.table('github') this.smms = this.table('smms') this.upyun = this.table('upyun') this.imgur = this.table('imgur') this.s3plist = this.table('s3plist') this.webdavplist = this.table('webdavplist') } } export const fileCacheDbInstance = new FileCacheDb()