manyToMany<E extends RelationalDatumEntity, R extends DatumEntityInterface, P extends DatumEntityInterface> static method
DatumRelationSpec<E, R>
manyToMany<E extends RelationalDatumEntity, R extends DatumEntityInterface, P extends DatumEntityInterface>(
- String name, {
- required DatumFieldSpec<
P, String> pivotSelfKey, - required DatumFieldSpec<
P, String> pivotOtherKey, - String localKey = 'id',
- String otherLocalKey = 'id',
- CascadeDeleteBehavior cascadeDelete = CascadeDeleteBehavior.none,
A many-to-many relation through a registered pivot entity P:
pivot rows whose pivotSelfKey equals this entity's id select the R
rows referenced by their pivotOtherKey. Both keys are the pivot's
typed field specs, so the whole join is spelled in one vocabulary:
static final tagsRel = DatumRelationSpec.manyToMany<Ticket, Tag, TicketTag>(
'tags',
pivotSelfKey: TicketTag.ticketIdField,
pivotOtherKey: TicketTag.tagIdField,
);
Implementation
static DatumRelationSpec<E, R> manyToMany<E extends RelationalDatumEntity, R extends DatumEntityInterface, P extends DatumEntityInterface>(
String name, {
required DatumFieldSpec<P, String> pivotSelfKey,
required DatumFieldSpec<P, String> pivotOtherKey,
String localKey = 'id',
String otherLocalKey = 'id',
CascadeDeleteBehavior cascadeDelete = CascadeDeleteBehavior.none,
}) =>
DatumRelationSpec<E, R>._manyToMany(
name,
pivotType: P,
pivotSelfKey: pivotSelfKey.name,
pivotOtherKey: pivotOtherKey.name,
localKey: localKey,
otherLocalKey: otherLocalKey,
cascadeDelete: cascadeDelete,
);