VidStudio SDK reference
    Preparing search index...

    Interface StorageAdapter

    Abstract storage contract. IndexedDB is the default implementation, but any backend (SQLite, REST API, in-memory) can implement this.

    interface StorageAdapter {
        add<T>(storeName: string, record: T): Promise<void>;
        delete(storeName: string, id: string): Promise<void>;
        deleteAllByIndex(
            storeName: string,
            indexName: string,
            value: string,
        ): Promise<void>;
        get<T>(storeName: string, id: string): Promise<T | undefined>;
        getAll<T>(storeName: string): Promise<T[]>;
        getAllByIndex<T>(
            storeName: string,
            indexName: string,
            value: string,
        ): Promise<T[]>;
        put<T>(storeName: string, record: T): Promise<void>;
        replaceAllByIndex<T>(
            storeName: string,
            indexName: string,
            value: string,
            records: T[],
        ): Promise<void>;
    }

    Implemented by

    Index
    • Insert a new record. Rejects if id already exists.

      Type Parameters

      • T

      Parameters

      • storeName: string
      • record: T

      Returns Promise<void>

    • Delete a record by primary key

      Parameters

      • storeName: string
      • id: string

      Returns Promise<void>

    • Delete all records matching an index value (cascade helper)

      Parameters

      • storeName: string
      • indexName: string
      • value: string

      Returns Promise<void>

    • Get a single record by its primary key

      Type Parameters

      • T

      Parameters

      • storeName: string
      • id: string

      Returns Promise<T | undefined>

    • Get all records in a store

      Type Parameters

      • T

      Parameters

      • storeName: string

      Returns Promise<T[]>

    • Get all records matching a specific index value (foreign key lookup)

      Type Parameters

      • T

      Parameters

      • storeName: string
      • indexName: string
      • value: string

      Returns Promise<T[]>

    • Replace an existing record (full replacement by primary key).

      Type Parameters

      • T

      Parameters

      • storeName: string
      • record: T

      Returns Promise<void>

    • Atomically replace every record matching an index value with a new set, in a single transaction: delete all matches, then insert records. A concurrent read either sees the entire old set or the entire new set, never a partial mix, and a mid-write failure rolls back the whole change.

      Type Parameters

      • T

      Parameters

      • storeName: string
      • indexName: string
      • value: string
      • records: T[]

      Returns Promise<void>