Delete store definition

This commit is contained in:
omaroughriss 2025-11-27 16:43:49 +01:00
parent 71d0d14095
commit f74fcabec7

View File

@ -2,59 +2,21 @@ import Services from './service';
export class Database { export class Database {
private static instance: Database; private static instance: Database;
private db: IDBDatabase | null = null;
private dbName: string = '4nk';
private dbVersion: number = 1;
private serviceWorkerRegistration: ServiceWorkerRegistration | null = null; private serviceWorkerRegistration: ServiceWorkerRegistration | null = null;
private messageChannel: MessageChannel | null = null;
private messageChannelForGet: MessageChannel | null = null;
private serviceWorkerCheckIntervalId: number | null = null; private serviceWorkerCheckIntervalId: number | null = null;
private storeDefinitions = { private indexedDBWorker: Worker | null = null;
AnkLabels: { private messageIdCounter: number = 0;
name: 'labels', private pendingMessages: Map<number, { resolve: (value: any) => void; reject: (error: any) => void }> = new Map();
options: { keyPath: 'emoji' },
indices: [],
},
AnkWallet: {
name: 'wallet',
options: { keyPath: 'pre_id' },
indices: [],
},
AnkProcess: {
name: 'processes',
options: {},
indices: [],
},
AnkSharedSecrets: {
name: 'shared_secrets',
options: {},
indices: [],
},
AnkUnconfirmedSecrets: {
name: 'unconfirmed_secrets',
options: { autoIncrement: true },
indices: [],
},
AnkPendingDiffs: {
name: 'diffs',
options: { keyPath: 'value_commitment' },
indices: [
{ name: 'byStateId', keyPath: 'state_id', options: { unique: false } },
{ name: 'byNeedValidation', keyPath: 'need_validation', options: { unique: false } },
{ name: 'byStatus', keyPath: 'validation_status', options: { unique: false } },
],
},
AnkData: {
name: 'data',
options: {},
indices: [],
},
};
// Private constructor to prevent direct instantiation from outside // ============================================
private constructor() {} // INITIALIZATION & SINGLETON
// ============================================
private constructor() {
this.initIndexedDBWorker();
this.initServiceWorker();
}
// Method to access the singleton instance of Database
public static async getInstance(): Promise<Database> { public static async getInstance(): Promise<Database> {
if (!Database.instance) { if (!Database.instance) {
Database.instance = new Database(); Database.instance = new Database();