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:

By using Ecto.Model all the functionality above is included, but you can cherry pick the ones you want to use.

Source

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

primary_key(model)

Specs:

  • primary_key(t) :: any

Returns the model's primary key.

Raises Ecto.NoPrimaryKey if model has no primary key.

Source
put_primary_key(model, id)

Specs:

  • put_primary_key(t, any) :: t

Sets the model's primary key.

Raises Ecto.NoPrimaryKey if model has no primary key.

Source

Macros

scoped(field, opts)

Scopes a query to the local model.

Shorthand for from(var in __MODULE__, ...).

Source