Skip to content

Instantly share code, notes, and snippets.

View abadongutierrez's full-sized avatar
💻
working

Rafael Gutiérrez abadongutierrez

💻
working
View GitHub Profile
def start(_type, _args) do
import Supervisor.Spec, warn: false
# Define workers and child supervisors to be supervised
children = [supervisor(EctoTest.Repo, [])]
# See http://elixir-lang.org/docs/stable/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: EctoTest.Supervisor]
Supervisor.start_link(children, opts)
CREATE TABLE department
(
department_id serial NOT NULL,
name text NOT NULL,
PRIMARY KEY (department_id)
);
CREATE TABLE employee
(
employee_id serial NOT NULL,
config :ecto_test, EctoTest.Repo,
adapter: Ecto.Adapters.Postgres,
database: "ecto_test",
username: "postgres",
password: "",
hostname: "localhost"
config :ecto_test, ecto_repos: [EctoTest.Repo]
defmodule EctoTest.Repo do
use Ecto.Repo, otp_app: :ecto_test
end
def application do
[applications: [:logger, :ecto, :postgrex],
mod: {EctoTest, []}]
end
defp deps do
[{:postgrex, ">= 0.0.0"},
{:ecto, "~> 2.0.0"}]
end
.
├── README.md
├── config
│ └── config.exs
├── lib
│ └── ecto_test.ex
├── mix.exs
└── test
 ├── ecto_test_test.exs
 └── test_helper.exs
mix new ecto_test --sup
from e in Employee,
select: [e.name,
e.last_name,
e.salary]
SELECT
name, last_name, salary
FROM employees