@adobe/data - v0.10.30
    Preparing search index...

    Interface TransactionalStore<C, R, A, IX, PK>

    interface TransactionalStore<
        C extends Components = never,
        R extends ResourceComponents = never,
        A extends ArchetypeComponents<StringKeyof<C>> = never,
        IX extends IndexDeclarations<C> = {},
        PK extends string = never,
    > {
        archetypes: {
            readonly [K in string]: ArchetypeOrRouter<
                HasPartitionKey<A[K][number], PK>,
                { [Col in string]: (C & OptionalComponents)[Col] },
                ReadonlyArchetype<{ [Col in string]: (C & OptionalComponents)[Col] }>,
                Extract<A[K][number], never>,
            >
        };
        componentSchemas: { readonly [K in string]: Schema.Schema };
        indexes: { readonly [K in string | number | symbol]: Handle<C, IX[K]> };
        locate: (
            entity: number,
        ) => null | { archetype: ReadonlyArchetype; row: number };
        resources: { readonly [K in string]: R[K] };
        transactionStore: Store<C, R, A, IX, PK>;
        count<Include extends string>(
            include: ReadonlySet<string> | readonly Include[],
            options?: EntitySelectOptions<
                C & OptionalComponents,
                Pick<C & RequiredComponents & OptionalComponents, Include>,
            >,
        ): number;
        ensureArchetype<const CC extends string>(
            components: ReadonlySet<CC> | readonly CC[],
        ): HasPartitionKey<CC, PK> extends true
            ? Router<
                { [K in string]: (C & OptionalComponents)[K] },
                Extract<CC, never>,
            >
            : ReadonlyArchetype<{ [K in string]: (C & OptionalComponents)[K] }>;
        ensureArchetype<const CC extends string>(
            components: ReadonlySet<CC> | readonly CC[],
            partitionValues: { readonly [K in string]: (C & OptionalComponents)[K] },
        ): ReadonlyArchetype<{ [K in string]: (C & OptionalComponents)[K] }>;
        execute(
            transactionFunction: (t: Store<C, R, A, IX, PK>) => number | void,
            options?: { intermediate?: boolean; userId?: string | number },
        ): TransactionResult<C>;
        extend<S extends Store.Schema<any, any, any, {}>>(
            schema: S,
        ): TransactionalStore<
            C & (
                S extends Store.Schema<XC, any, any, {}> ? FromSchemas<XC> : never
            ),
            R & (S extends Store.Schema<any, XR, any, {}> ? FromSchemas<XR> : never),
            A & (S extends Store.Schema<any, any, XA, {}> ? XA : never),
            IX,

                | PK
                | (
                    S extends Store.Schema<XC, any, any, {}>
                        ? PartitionKeysOf<XC>
                        : never
                ),
        >;
        get<K extends string>(entity: number, component: K): undefined | C[K];
        pruneToSchema(keep: ReadonlySet<string>): void;
        queryArchetypes<Include extends string>(
            include: ReadonlySet<string> | readonly Include[],
            options?: ArchetypeQueryOptions<C, PK>,
        ): readonly ReadonlyArchetype<Pick<C & OptionalComponents, Include>>[];
        read<T>(
            entity: number,
            archetype: ReadonlyArchetype<T> | Archetype<T, never>,
        ): null | Readonly<T>;
        read<const K extends string | number | symbol>(
            entity: number,
            components: readonly K[],
        ): null | Readonly<Pick<EntityReadValues<C>, K>>;
        read(entity: number): null | EntityReadValues<C>;
        select<Include extends string>(
            include: ReadonlySet<string> | readonly Include[],
            options?: EntitySelectOptions<
                C & OptionalComponents,
                Pick<C & RequiredComponents & OptionalComponents, Include>,
            >,
        ): readonly number[];
        toData(options?: ToDataOptions): unknown;
    }

    Type Parameters

    Hierarchy (View Summary)

    Index

    Properties

    archetypes: {
        readonly [K in string]: ArchetypeOrRouter<
            HasPartitionKey<A[K][number], PK>,
            { [Col in string]: (C & OptionalComponents)[Col] },
            ReadonlyArchetype<{ [Col in string]: (C & OptionalComponents)[Col] }>,
            Extract<A[K][number], never>,
        >
    }
    componentSchemas: { readonly [K in string]: Schema.Schema }
    indexes: { readonly [K in string | number | symbol]: Handle<C, IX[K]> }
    locate: (entity: number) => null | { archetype: ReadonlyArchetype; row: number }
    resources: { readonly [K in string]: R[K] }
    transactionStore: Store<C, R, A, IX, PK>

    Methods

    • Execute a transaction on the store. The transactionFunction must NOT directly mutate archetype rows as those changes would not be captured. Instead, use the store's update and delete and archetype insert methods to make changes.

      Parameters

      • transactionFunction: (t: Store<C, R, A, IX, PK>) => number | void

        A function that takes the store as an argument and performs some operations on it.

      • Optionaloptions: { intermediate?: boolean; userId?: string | number }

      Returns TransactionResult<C>

      A promise that resolves when the transaction is complete.

    • Read exactly the components of archetype. A membership GATE: returns null unless the entity is a superset of archetype. The result is narrowed to the archetype's own row — reading a component outside archetype off the result is a compile error (use a wider archetype, the component-list overload, or read(entity)).

      Type Parameters

      • T

      Parameters

      Returns null | Readonly<T>

    • Read a chosen subset of an entity's components.

      A pure PROJECTION, not a membership gate: returns null only when the entity does not exist. A requested component the entity does not have comes back absent — the field stays optional in the result, exactly as from the full read(entity).

      Prefer this over read(entity) when only a few fields are needed: it names the exact components touched, so db.derive can scope its recompute to just those fields instead of the whole entity. id is not a readable component (you already hold it); the element type is inferred as a literal union.

      Type Parameters

      • const K extends string | number | symbol

      Parameters

      • entity: number
      • components: readonly K[]

      Returns null | Readonly<Pick<EntityReadValues<C>, K>>

    • Parameters

      • entity: number

      Returns null | EntityReadValues<C>

    • Serialize the store to a plain snapshot. When copy is true the snapshot is detached from the live store (column/entity buffers are copied) so it remains valid after subsequent mutations; otherwise it references live buffers and is only valid until the next mutation. See Database.toData() for the bug this copy flag addresses for transient-bearing strategies.

      options.scope selects which persistent quadrants to emit; omit for all.

      Parameters

      Returns unknown