xerions/ecdo

Name: ecdo

Owner: xerions

Description: Ecdo is ecto dynamic query builder

Created: 2015-07-03 11:14:33.0

Updated: 2018-02-21 07:53:49.0

Pushed: 2016-03-30 07:54:47.0

Homepage: null

Size: 42

Language: Elixir

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Ecdo Build Status Coverage Status

Like an ecto, but dynamic. EcDo. Ecto is a domain specific language for writing queries and interacting with databases in Elixir. Ecdo is a dynamic interface for ecto.

Ecdo was build for accessing it from erlang(elixir need to be in path) or simplify building dynamic interface, for example API.

Example of using from erlang:

xir.Ecdo':query({<<"weather">>, 'Elixir.Weather'}, #{<<"where">> => [{'==', <<"weather.id">>, 1}]})
xir.Ecdo':query({<<"weather">>, 'Elixir.Weather'}, #{<<"where">> => <<"weather.id == 1">>})

Example of use from elixir:

.query {"weather", Weather}, %{"where" => "weather.id == 1"}

Simple example of building API:

odule Weather.Api do
f json(json) do
map = Poison.decode! json
# may be restrict something
Ecdo.query({"weather", Weather}, map) |> Repo.all
d


ample of use:

her.Api.json ~S({"where": "weather.temp_lo > 25", "limit": 10})

Due to some direct manipulations with ecto intern AST, ecdo aims to have always close to 100% of test cover.

Usage

You need to add both Ecdo and the database adapter as a dependency to your mix.exs file. The supported databases and their adapters are:

Database | Ecto Adapter | Dependency :———————- | :——————— | :——————- PostgreSQL | Ecto.Adapters.Postgres | postgrex MySQL | Ecto.Adapters.MySQL | mariaex MSSQL | Tds.Ecto | tds_ecto SQLite3 | Sqlite.Ecto | sqlite_ecto

For example, if you want to use MySQL, add to your mix.exs file:

 deps do
:mariaex, ">= 0.0.0"},
:ecdo, "~> 0.1.0"}]

and update your applications list to include both projects:

application do
pplications: [:mariaex, :ecdo]]


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.