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 byincludeopt to JaSerializer.format/4data- A list of structs representing the data.identifiers- Should "resource identifiers be included, options are:when_includedand:always. Defaults to:when_includedlinks- A keyword list of links,selfandrelatedare 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,
}
}
endSee JaSerializer.DSL.has_many/2 for information on defining different types of relationships.