Skip to content

zweifisch/eno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Eno

Build Status

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:

  1. 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.

About

Lightweight SQL toolkit for Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages