dyna-record
    Preparing search index...

    Interface RelatedEntityCondition<T>

    A guard on one entity of a HasMany or HasAndBelongsToMany relationship.

    A many-valued relationship has many possible targets, so the guard names one by id. The write also verifies, in the same transaction, that the id is actually related: a HasMany child's foreign key points at this entity, or the HasAndBelongsToMany link exists.

    Naming the same id twice in one relationship is a FilterError. An id that is not related fails the write with a plain ConditionalCheckFailedError, not a WriteConditionFailedError, inside the TransactionWriteFailedError.

    // Guard one of a Customer's Orders
    const order: RelatedEntityCondition<Order> = {
    id: "order-1",
    condition: { total: { $lt: 100 } }
    };

    // Rename a Customer only while order-1 is theirs and still pending
    await Customer.update(
    "customer-1",
    { name: "Jane Smith" },
    { condition: { orders: [{ id: "order-1", condition: { status: "pending" } }] } }
    );
    interface RelatedEntityCondition<T extends default> {
        condition: TargetCondition<T>;
        id: string;
    }

    Type Parameters

    • T extends default

      The related entity.

    Index

    Properties

    Properties

    condition: TargetCondition<T>

    The condition its row must meet.

    id: string

    The related entity's id.