AbstractStaticcreateCreate a JoinTable entry Adds denormalized copy of the related entity to each associated Entity's partition
When a write condition is given, links only if every guard on the entities being linked holds, in the same transaction.
The foreign key values of the entities to link
Optionaloptions: JoinTableCreateOptions<ThisClass>Optional operation options: the referentialIntegrityCheck flag and a write condition on the entities being linked, checked in the same transaction as the link. See JoinTableCreateOptions
FilterError Before anything is read or written, when the write condition is invalid.
NotFoundError Before anything is written, when either entity does not exist. The message names each missing entity, such as Entities not found: (Store: store-9).
TransactionWriteFailedError When DynamoDB cancels the transaction. Its errors hold a WriteConditionFailedError for each guarded entity whose condition failed, and a ConditionalCheckFailedError for a library check that failed, such as the entities already being linked.
// Link only while the Customer is active and the Store is open
await CustomerStore.create(
{ customerId: "customer-1", storeId: "store-1" },
{
condition: {
customerId: { target: { status: "active" } },
storeId: { target: { status: "open" } }
}
}
);
StaticdeleteDelete a JoinTable entry Deletes denormalized records from each associated Entity's partition
When a write condition is given, unlinks only if every guard on the entities being unlinked holds, in the same transaction.
The foreign key values of the entities to unlink
Optionaloptions: JoinTableDeleteOptions<ThisClass>Optional operation options: a write condition on the entities being unlinked, checked in the same transaction as the unlink. See JoinTableDeleteOptions
FilterError Before anything is written, when the write condition is invalid.
TransactionWriteFailedError When DynamoDB cancels the transaction. Its errors hold a WriteConditionFailedError for each guarded entity whose condition failed, and a ConditionalCheckFailedError for a library check that failed, such as the entities not being linked or a guarded entity not existing.
Abstract class representing a join table for HasAndBelongsToMany relationships. This class should be extended for specific join table implementations. It is virtual and not persisted to the database but manages the denormalized records in each related entity's partition.
Declare each foreign key with the entity it references,
ForeignKey<Target>, so a write condition oncreateordeletecan guard that entity's row.Example