View Source ExTeal.Fields.HasMany (ExTeal v0.27.0)

The HasMany field corresponds to a has_many ecto relationship. For example, let's assume a User schema has many Post schema. We may add the relationship to our User ExTeal resource like so:

alias ExTeal.Fields.HasMany

HasMany.make(:posts)

Summary

Functions

Link to this function

apply_options_for(field, model, conn, type)

View Source

Callback implementation for ExTeal.Field.apply_options_for/4.

Callback implementation for ExTeal.Field.default_sortable/0.

Callback implementation for ExTeal.Field.filterable_as/0.

Link to this function

make(name, label \\ nil)

View Source

Callback implementation for ExTeal.Field.make/2.

Callback implementation for ExTeal.Field.sanitize_as/0.

Link to this function

value_for(field, model, method)

View Source

Callback implementation for ExTeal.Field.value_for/3.

Link to this function

with_index_fields(has_many_field, index_fields)

View Source
@spec with_index_fields(ExTeal.Field.t(), [ExTeal.Field.t()]) :: ExTeal.Field.t()

Define a list of custom index fields to use when displaying the has many relationship.

HasMany.make(:posts)
|> HasMany.with_index_fields([
  Text.make(:title)
])

This list of fields will override the fields used when displaying, sorting, and filtering the related table.