quick
quick copied to clipboard
.create() support on belongsToMany and hasManyThrough
.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:
- Implement .create() on these relationships in such a way that the intermediate entity is also created, and
- 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.