quick icon indicating copy to clipboard operation
quick copied to clipboard

.create() support on belongsToMany and hasManyThrough

Open MordantWastrel opened this issue 4 years ago • 0 comments

.attach() will create an intermediate entity (with one caveat) but there is no analog for .create() on entities involving pivot tables. The function works -- it creates the target entity -- but it doesn't create the intermediate entity, and it returns the relationship object rather than the newly created entity.

Two things to solve:

  1. Implement .create() on these relationships in such a way that the intermediate entity is also created, and
  2. Either supply a mechanism to populate non-key fields on the intermediate entity, or else require that the intermediate entity be a Quick entity, so we can use interception points like preSave if we need fields set besides the two key fields.

MordantWastrel avatar Jun 02 '20 12:06 MordantWastrel