One-to-many and one-to-one
Relationships between models are defined using the
@relate directive. The directive's
on argument takes an array of objects consisting of a
from column and a
to column. For a one-to-many or one-to-one relationship, there is a single object with the
from identifying the column on this model and the
to identifying the column on the related model. Note: regardless of where the foreign key is related, the
from always reflects the current model.
Many-to-many relationships are defined similarly, but also provide a
through argument to identify the join or junction table. They also include two "on" objects -- one joining the current model's table to the junction table and one joining the junction table to the related model.
Instead of just returning a list of the related type, a relationship field may instead return an object that allows us to paginate over and aggregate the related type's values. To indicate that the relationship field is using this pattern, make sure to provide a value for
The only possible value for
pagination currently supported is
OFFSET. For additional details around pagination, see here.