dyna-record
    Preparing search index...

    Interface ForeignKeyTargetGuard<T>

    A guard on the row a foreign key references, keyed by the foreign key property.

    The target wrapper says the condition applies to the referenced entity's row, not to the foreign key's own value. It is offered on a foreign key declared with its target type, ForeignKey<Target> or NullableForeignKey<Target>, that does not back a BelongsTo relationship: a join table's foreign keys, the child side of a one-way HasMany, and a standalone foreign key.

    A bare ForeignKey presents UntypedForeignKeyTargetError instead, and a foreign key backing a BelongsTo presents BelongsToForeignKeyTargetError. A key holds either a condition on its own value or a target guard, never both.

    // PaymentMethod declares customerId: ForeignKey<Customer> and no BelongsTo
    const condition: WriteCondition<PaymentMethod> = {
    customerId: { target: { name: "Jane" } }
    };

    // Order declares a standalone storeId: ForeignKey<Store>
    await Order.update(
    "order-1",
    { total: 90 },
    { condition: { storeId: { target: { status: "open" } } } }
    );
    interface ForeignKeyTargetGuard<T extends default> {
        target: TargetCondition<T>;
    }

    Type Parameters

    • T extends default

      The entity the foreign key references.

    Index

    Properties

    Properties

    The condition the referenced row must meet.