| 34 | } |
| 35 | |
| 36 | async save(workspaces: any[]): Promise<void> { |
| 37 | if (!this.db) throw new Error("Database not initialized"); |
| 38 | |
| 39 | const transaction = this.db.transaction("workspaces", "readwrite"); |
| 40 | const store = transaction.objectStore("workspaces"); |
| 41 | |
| 42 | return new Promise((resolve, reject) => { |
| 43 | // Clear existing data |
| 44 | store.clear(); |
| 45 | |
| 46 | // Add new workspaces |
| 47 | workspaces.forEach((workspace) => { |
| 48 | store.add(workspace); |
| 49 | }); |
| 50 | |
| 51 | transaction.oncomplete = () => resolve(); |
| 52 | transaction.onerror = () => reject(transaction.error); |
| 53 | }); |
| 54 | } |
| 55 | |
| 56 | async query(): Promise<any[]> { |
| 57 | if (!this.db) throw new Error("Database not initialized"); |