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 |
Functions
Specs:
- primary_key(t) :: any
Returns the model’s primary key.
Raises Ecto.NoPrimaryKey
if model has no primary key.