Ecto.Associations.BelongsTo.Proxy
A belongs_to association.
Create
A new struct of the associated model can be created with struct/2.
defmodule Comment do
use Ecto.Model
schema "comments" do
belongs_to :post, Post
end
end
comment = %Comment{}
struct(comment.post, []) #=> %Post{}
Reflection
Any association module will generate the __assoc__ function that can be
used for runtime introspection of the association.
__assoc__(:loaded, assoc)- Returns the loaded entities or:not_loaded;__assoc__(:loaded, value, assoc)- Sets the loaded entities;__assoc__(:target, assoc)- Returns the model where the association was defined;__assoc__(:name, assoc)- Returns the name of the association field on the model;__assoc__(:new, name, target)- Creates a new association with the given name and target;
Summary
| get(arg1) | Returns the associated struct. Raises |
| loaded?(arg1) | Returns |