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>(
  1. String name, {
  2. required DatumFieldSpec<P, String> pivotSelfKey,
  3. required DatumFieldSpec<P, String> pivotOtherKey,
  4. String localKey = 'id',
  5. String otherLocalKey = 'id',
  6. 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,
    );