dyna-record
    Preparing search index...

    Interface BelongsToForeignKeyTargetError<Relationship>

    The error surface presented when a target guard is written on a foreign key that backs a BelongsTo relationship.

    Never written by hand: it is the type a target takes on such a key, so the compile error on the guard quotes its message and names the relationship to use.

    The referenced row is guarded under the relationship key instead, so that one parent row is never reachable by two keys.

    // Order declares customerId: ForeignKey<Customer> and a BelongsTo customer
    await Order.update(
    "order-1",
    { total: 90 },
    // Compile error naming this surface, with relationship: "customer"
    { condition: { customerId: { target: { status: "active" } } } }
    );

    // Guard the Customer under the relationship instead
    await Order.update(
    "order-1",
    { total: 90 },
    { condition: { customer: { status: "active" } } }
    );
    interface BelongsToForeignKeyTargetError<Relationship> {
        __writeConditionError: "this foreign key backs a BelongsTo relationship; guard the row it references under the relationship key";
        relationship: Relationship;
    }

    Type Parameters

    • Relationship

      The relationship key to guard the row under.

    Index

    Properties

    __writeConditionError: "this foreign key backs a BelongsTo relationship; guard the row it references under the relationship key"
    relationship: Relationship