Ecto.Model
Models are Elixir modules with Ecto-specific behaviour.
This module is an “umbrella” module that adds a bunch of functionality to your module:
Ecto.Model.Schema- provides the API necessary to define schemas;Ecto.Model.Callbacks- to be implemented;Ecto.Model.Validations- helpers for validations;
By using Ecto.Model all the functionality above is included,
but you can cherry pick the ones you want to use.
Summary↑
| primary_key(model) | Returns the model’s primary key |
| put_primary_key(model, id) | Sets the model’s primary key |
| scoped(field, opts) | Scopes a query to the local model |
Types ↑
t :: %{}
Functions
Specs:
- primary_key(t) :: any
Returns the model’s primary key.
Raises Ecto.NoPrimaryKey if model has no primary key.
Specs:
Sets the model’s primary key.
Raises Ecto.NoPrimaryKey if model has no primary key.
Macros
Scopes a query to the local model.
Shorthand for from(var in __MODULE__, ...).