dyna-record
    Preparing search index...

    Type Alias JoinTableCondition<J>

    JoinTableCondition: {
        [P in JoinTableForeignKeys<J>]?: ForeignKeyTargetGuardFor<
            AssertDynaRecord<ExtractForeignKeyTarget<J[P]>>,
        >
    }

    The condition JoinTable.create and JoinTable.delete accept, keyed by the join table's foreign key properties.

    A join table has no row of its own, so each key guards the entity its foreign key references, wrapped in target to make clear that the condition applies to that entity's row rather than to the key's value. Each target is typed from the foreign key's own type parameter, so the key must be declared ForeignKey<Target>: on a bare ForeignKey the guard is a compile error naming the missing type parameter (see UntypedForeignKeyTargetError).

    Each target takes a TargetCondition on the referenced entity, in the full query-filter vocabulary, null and $or included. A guard also requires its entity to exist, even with referentialIntegrityCheck: false. When a guard fails, the WriteConditionFailedError names the join table as its entity and the join table's keys as its id, for example customerId=customer-1, storeId=store-1.

    Type Parameters

    • J

      The join table class.

    class CustomerStore extends JoinTable<Customer, Store> {
    public readonly customerId: ForeignKey<Customer>;
    public readonly storeId: ForeignKey<Store>;
    }

    // Link a Customer to a Store only if the Store is in Springfield
    const condition: JoinTableCondition<CustomerStore> = {
    storeId: { target: { "address.city": "Springfield" } }
    };