View Source ExTeal.Resource.Model behaviour (ExTeal v0.27.0)
Provides the model/0
callback used to customize the resource served.
This behaviour is used by all ExTeal actions.
Summary
Callbacks
Array of default field filters to be used when there are no filters present
Must return the module implementing Ecto.Schema
to be represented.
The fields that should be searched
Returns the singularized version of the title to display on forms.
Returns the subtitle to display in relationships.
Returns the thumbnail to display in search.
Returns the title to display in the side bar.
Returns the title to display in relationships.
Returns the uri to display in the side bar.
Callbacks
@callback default_filters() :: [map()] | nil
Array of default field filters to be used when there are no filters present
@callback model() :: module()
Must return the module implementing Ecto.Schema
to be represented.
Example:
def model, do: MyApp.Models.Post
Defaults to the name of the resource, for example the resource
MyApp.V1.PostResource
would serve the MyApp.Post
model.
Used by the default implementations for handle_create/2
, handle_update/3
,
and records/1
.
@callback search() :: [atom()]
The fields that should be searched
@callback singular_title() :: String.t()
Returns the singularized version of the title to display on forms.
Returns the subtitle to display in relationships.
Defaults to looking for name or title fields, falls back to the schemas name appended by it's id
Returns the thumbnail to display in search.
Defaults to looking for name or title fields, falls back to the schemas name appended by it's id
@callback title() :: String.t()
Returns the title to display in the side bar.
Defaults to finding the title from the resource modules name
Returns the title to display in relationships.
Defaults to looking for name or title fields, falls back to the schemas name appended by it's id
@callback uri() :: String.t()
Returns the uri to display in the side bar.
Defaults to finding the uri from the resource modules name