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 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) |
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 TABLE department | |
| ( | |
| department_id serial NOT NULL, | |
| name text NOT NULL, | |
| PRIMARY KEY (department_id) | |
| ); | |
| CREATE TABLE employee | |
| ( | |
| employee_id serial NOT NULL, |
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
| config :ecto_test, EctoTest.Repo, | |
| adapter: Ecto.Adapters.Postgres, | |
| database: "ecto_test", | |
| username: "postgres", | |
| password: "", | |
| hostname: "localhost" | |
| config :ecto_test, ecto_repos: [EctoTest.Repo] |
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 EctoTest.Repo do | |
| use Ecto.Repo, otp_app: :ecto_test | |
| 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
| def application do | |
| [applications: [:logger, :ecto, :postgrex], | |
| mod: {EctoTest, []}] | |
| 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
| defp deps do | |
| [{:postgrex, ">= 0.0.0"}, | |
| {:ecto, "~> 2.0.0"}] | |
| 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
| . | |
| ├── README.md | |
| ├── config | |
| │ └── config.exs | |
| ├── lib | |
| │ └── ecto_test.ex | |
| ├── mix.exs | |
| └── test | |
| ├── ecto_test_test.exs | |
| └── test_helper.exs |
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
| mix new ecto_test --sup |
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 e in Employee, | |
| select: [e.name, | |
| e.last_name, | |
| e.salary] |
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
| SELECT | |
| name, last_name, salary | |
| FROM employees |