This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Repo.all from u in User, | |
preload: [{:investiment_funds, :institution}, :transfers] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Repo.all from u in User, | |
preload: [:investiment_funds, :transfers] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Repo.all from u in User, | |
preload: [:investiment_funds] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a query | |
query = from u in User, where: u.age > 18 | |
# Extend the query | |
query = from u in query, select: u.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
classes = (from klass in Class, | |
order_by: klass.created_at) | |
query = (from course in Course, | |
preload: [classes: ^classes]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(from c in Course, | |
join: class in assoc(c, :classes), | |
preload: [classes: class], | |
select: c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(from c in Course, | |
preload: [classes: class], | |
select: c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(from c in Course, | |
select: c) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def changeset(user, params \\ %{}) do | |
user | |
|> cast(params, [:name, :email, :age]) | |
|> validate_required([:name, :email]) | |
|> validate_format(:email, ~r/@/) | |
|> validate_inclusion(:age, 18..100) | |
|> unique_constraint(:email) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Course do | |
use Ecto.Schema | |
schema "courses" do | |
field :name | |
field :description | |
has_many :classes, Class, on_delete: :delete_all | |
timestamps() |
NewerOlder