@aicacia/db
    Preparing search index...

    Interface SourceAdapter<T, Q>

    Persistence adapter for multi-document collections.

    interface SourceAdapter<T, Q = unknown> {
        create(doc: T): Promise<void>;
        delete(id: string): Promise<void>;
        getStatus(): AdapterStatus;
        subscribe(
            onUpdate: (docs: T[]) => void,
            onError: (error: Error) => void,
            query?: Q,
        ): UnsubscribeFn;
        update(id: string, changes: Partial<T>): Promise<void>;
    }

    Type Parameters

    • T
    • Q = unknown

    Implemented by

    Index

    Methods

    • Create a document.

      Parameters

      • doc: T

      Returns Promise<void>

    • Delete a document by id.

      Parameters

      • id: string

      Returns Promise<void>

    • Subscribe to raw document updates and return an unsubscribe function.

      Parameters

      • onUpdate: (docs: T[]) => void
      • onError: (error: Error) => void
      • Optionalquery: Q

      Returns UnsubscribeFn

    • Update a document by id.

      Parameters

      • id: string
      • changes: Partial<T>

      Returns Promise<void>