Skip to content

krns/postgrest-ex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postgrestex

Status: POC

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.2"}
  ]
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

Initialize and read from a table

First, import Postgrestex

Then do any one of the following options:

Create

Example usage:

init("public") \
      |> from("users") \
      |> insert(
        %{username: "nevergonna", age_range: "[1,2)", status: "ONLINE", catchphrase: "giveyouup"},
        false
      ) \
      |> call()

Read

Example usage:

init("public") \
    |> from("messages") \
    |> select(["id", "username"]) \
    |> call()

Update

Example usage:

  init("public") \
    |> from("users") \
    |> eq("username", "supabot") \
    |> update(%{status: "OFFLINE"}) \
    |> call()

Delete

Example usage:

init("public") \
  |> from("users") \
  |> eq("username", "nevergonna") \
  |> eq("status", "ONLINE") \
  |> delete() \
  |> call()

Testing

Run mix test

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 88.8%
  • PLpgSQL 11.2%