zweifisch / Eno
Licence: mit
Lightweight SQL toolkit for Elixir
Programming Languages
elixir
2628 projects
Eno
Lightweight SQL toolkit for elixir inspired by yesql and ragtime.
For the moment only PostgreSQL is supported, and you need to add postgrex as a dependency.
Installation
It's available in Hex, the package can be installed as:
-
Add eno to your list of dependencies in
mix.exs
:def deps do [{:eno, "~> 0.0.1"}] end
Usage
lib/yourapp/repo.ex
defmodule YourApp.Repo do
use Eno
end
lib/yourapp/repo.sql
-- name: user_list
select * from users offset :offset limit :limit;
-- name: user_get
select * from users where user_id = :id;
lib/yourapp.ex
children = [
worker(YourApp.Repo, []),
]
config/config.ex
config :eno, YourApp.Repo,
adapter: Eno.Adapters.Postgres,
hostname: "localhost",
username: "user",
password: "pass",
database: "db"
finally
iex> YourApp.Repo.user_list offset: 0, limit: 10
iex> YourApp.Repo.user_get 1
Migration
$ mix eno.gen.migration init_users
priv/migrations/repo/20160507022535_init_users.up.sql
create table users (id SERIAL PRIMARY KEY, name varchar(255) NOT NULL UNIQUE);
priv/migrations/repo/20160507022535_init_users.down.sql
drop table users;
config/config.ex
config :yourapp,
eno_repos: [YourApp.Repo]
up
$ mix eno.migrate [-r YourApp.Repo]
down
$ mix eno.rollback [-r YourApp.Repo]
Status
Not ready for production use yet. The API is subject to change.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].