Postgrestex

Elixir Postgrestex library for Postgrest. The design mirrors that of postgrest-py

Installation

If available in Hex, the package can be installed by adding postgrestex to your list of dependencies in mix.exs:

def deps do
  [
    {:postgrestex, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/postgrestex.

Getting Started

TODOS:

Initialize and read from a table

First, import Postgrestex

Then do:

 init("api") |> from("todos") |> call()

Create

init("api") |> from("todos") |> insert(%{"name": "Singapore", "capital": "Singapore" }, False) |> call()

Read

init("api") |> from("todos") |> select(["id", "name"]) |>call()

Update

Note: Bear in mind to update the <insert your token field> to use your own jwt token.

init("api") |> from("todos") |> eq("id", "1") |> update(%{"id": "5"}) |> auth("<insert your token here>")|> call()

Delete

Note: Bear in mind to update the <insert your token field> to use your own jwt token.

init("api") |> from("todos") |> eq("name", "Singapore") |> delete(%{"id": 1})|> auth("<insert your token here>") |> call()

Testing

Note: This is WIP

To run the tests, first install postgrest and do postgrest tutorial.conf

Then run mix test