import { SavingContext, USL } from "../ts-refs/trans-render/XV/types.js"; import { BaseIndexedDB } from "./BaseIndexedDB.js"; export class IndexedDBObject extends BaseIndexedDB { get dbOptions(){ return { keyPath: 'key'} } async assign(obj: Partial, ctx?: SavingContext){ const USLs: Set = ctx?.USLs ?? new Set(); for(const key in obj){ await this.#setItem(key, obj[key]); const protocol = 'indexedDB'; USLs.add(protocol as USL); const root = `${protocol}://${this.dbName}/${this.storeName}`; USLs.add(root as USL); const usl = `${root}/${key}`; USLs.add(usl as USL); } if(ctx === undefined){ postMessage(USLs); } } async #setItem(key: keyof TObject & string, value: any) { const resp = await this.idbAction('put', {key, value}); return resp; } async getProperty(key: keyof TObject) { return ((await this.idbAction('get', key)) as any).value; } }