Tutorial by Examples

This can be done in 3 steps : You must define an elixir module which use Ecto.Repo and register your app as an otp_app. defmodule Repo do use Ecto.Repo, otp_app: :custom_app end You must also define some config for the Repo which will allow you to connect to the database. Here is an...
If you have an Ecto.Queryable, named Post, which has a title and an description. You can fetch the Post with title: "hello" and description : "world" by performing : MyRepo.get_by(Post, [title: "hello", description: "world"]) All of this is possible beca...
To query a field which name is contained in a variable, use the field function. some_field = :id some_value = 10 from p in Post, where: field(p, ^some_field) == ^some_value
(From this answer) The example below adds an enumerated type to a postgres database. First, edit the migration file (created with mix ecto.gen.migration): def up do # creating the enumerated type execute("CREATE TYPE post_status AS ENUM ('published', 'editing')") # creating a...

Page 1 of 1