ja_serializer v0.18.1 JaSerializer.Relationship.HasMany View Source
Struct to represent a HasMany relationship.
The fields are:
serializer
- A Serializer (often a PhoenixView) implementing the JaSerializer.Serializer behaviour.include
- Should this relationship be included (sideloaded) by default. Overridden byinclude
opt to JaSerializer.format/4data
- A list of structs representing the data.identifiers
- Should "resource identifiers be included, options are:when_included
and:always
. Defaults to:when_included
links
- A keyword list of links,self
andrelated
are most common.name
- Name of the relationship, automatically set.
Used when defining relationships without the DSL using the JaSerializer.relationships/2 callback. For example:
def relationships(article, _conn) do
%{
comments: %HasMany{
serializer: MyApp.CommentView,
include: true,
data: article.comments,
}
}
end
See JaSerializer.DSL.has_many/2 for information on defining different types of relationships.