# Supabase

A Supabase client for Elixir.

[![.github/workflows/ci.yml](]( [![Coverage Status](](

With this library you can work with [Supabase]( At the moment there's
functionality for

- **auth**
- **database/postgrest**
- **storage**

**auth** and **database** are implemented in different libraries.
[gotrue-elixir]( for **auth** and
[postgrest-ex]( for **database**.

**supabase-elixir** handles the correct initializtion from a common config.

## Installation

def deps do
    {:supabase, "~> 0.2.0"}

## Configuration

You can configure your Supabase project url and api anon key so that **supabase-elixir**
can handle the correct initialization of the different clients:

config :supabase,
  base_url: System.get_env("SUPABASE_URL"),
  api_key: System.get_env("SUPABASE_KEY")

## Auth / GoTrue

Uses [gotrue-elixir](

|> GoTrue.settings()

## Database / Postgrest

Uses [postgrest-ex](

import Supabase
import Postgrestex
|> from("profiles")
|> eq("Username", "Patrick")
|> json()
  body: [
      "avatar_url" => "avatar.jpeg",
      "id" => "blabla7d-411d-4ead-83d0-452343b",
      "updated_at" => "2021-05-02T21:05:37.258616+00:00",
      "username" => "Patrick",
      "website" => ""
  status: 200

# Or when in a user context with available JWT

# To use another schema than 'public' 'other_schema')

### Not depending on Application config

Supabase.init("", "my-api-key")

## Storage

The API tries to reflect the one of the offical [JS client](

{:ok, object} =
  |> Supabase.Storage.from("avatars")

# with user context
{:ok, object} =
  |> Supabase.Storage.from("avatars")


## Testing

The tests require a Supabase project (the **url** and **api key**) where **Row Level Security** is disabled for both, `BUCKET` and `OBJECT`.

export SUPABASE_TEST_URL="https://*********"
export SUPABASE_TEST_KEY="***"

mix test

# or with coverage
mix coveralls