• Stars
    star
    221
  • Rank 179,773 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unofficial Supabase client library for Go.

supabase-go

Unofficial Supabase client for Go. It is an amalgamation of all the libraries similar to the official Supabase client.

Installation

go get github.com/nedpals/supabase-go

Usage

Authenticate

import supa "github.com/nedpals/supabase-go"

func main() {
  supabaseUrl := "<SUPABASE-URL>"
  supabaseKey := "<SUPABASE-KEY>"
  supabase := supa.CreateClient(supabaseUrl, supabaseKey)

  ctx := context.Background()
  user, err := supabase.Auth.SignUp(ctx, supa.UserCredentials{
    Email:    "[email protected]",
    Password: "password",
  })
  if err != nil {
    panic(err)
  }

  fmt.Println(user)
}

Sign-In

import supa "github.com/nedpals/supabase-go"

func main() {
  supabaseUrl := "<SUPABASE-URL>"
  supabaseKey := "<SUPABASE-KEY>"
  supabase := supa.CreateClient(supabaseUrl, supabaseKey)

  ctx := context.Background()
  user, err := supabase.Auth.SignIn(ctx, supa.UserCredentials{
    Email:    "[email protected]",
    Password: "password",
  })
  if err != nil {
    panic(err)
  }

  fmt.Println(user)
}

Insert

import supa "github.com/nedpals/supabase-go"

type Country struct {
  ID      int    `json:"id"`
  Name    string `json:"name"`
  Capital string `json:"capital"`
}

func main() {
  supabaseUrl := "<SUPABASE-URL>"
  supabaseKey := "<SUPABASE-KEY>"
  supabase := supa.CreateClient(supabaseUrl, supabaseKey)

  row := Country{
    ID:      5,
    Name:    "Germany",
    Capital: "Berlin",
  }

  var results []Country
  err := supabase.DB.From("countries").Insert(row).Execute(&results)
  if err != nil {
    panic(err)
  }

  fmt.Println(results) // Inserted rows
}

Select

import supa "github.com/nedpals/supabase-go"

func main() {
  supabaseUrl := "<SUPABASE-URL>"
  supabaseKey := "<SUPABASE-KEY>"
  supabase := supa.CreateClient(supabaseUrl, supabaseKey)

  var results map[string]interface{}
  err := supabase.DB.From("countries").Select("*").Single().Execute(&results)
  if err != nil {
    panic(err)
  }

  fmt.Println(results) // Selected rows
}

Update

import supa "github.com/nedpals/supabase-go"

type Country struct {
  Name    string `json:"name"`
  Capital string `json:"capital"`
}

func main() {
  supabaseUrl := "<SUPABASE-URL>"
  supabaseKey := "<SUPABASE-KEY>"
  supabase := supa.CreateClient(supabaseUrl, supabaseKey)

  row := Country{
    Name:    "France",
    Capital: "Paris",
  }

  var results map[string]interface{}
  err := supabase.DB.From("countries").Update(row).Eq("id", "5").Execute(&results)
  if err != nil {
    panic(err)
  }

  fmt.Println(results) // Updated rows
}

Delete

import supa "github.com/nedpals/supabase-go"

func main() {
  supabaseUrl := "<SUPABASE-URL>"
  supabaseKey := "<SUPABASE-KEY>"
  supabase := supa.CreateClient(supabaseUrl, supabaseKey)

  var results map[string]interface{}
  err := supabase.DB.From("countries").Delete().Eq("name", "France").Execute(&results)
  if err != nil {
    panic(err)
  }

  fmt.Println(results) // Empty - nothing returned from delete
}

Roadmap

  • Auth support (1)
  • DB support (2)
  • Realtime
  • Storage
  • Testing

(1) - Thin API wrapper. Does not rely on the GoTrue library for simplicity (2) - Through postgrest-go

I just implemented features which I actually needed for my project for now. If you like to implement these features, feel free to submit a pull request as stated in the Contributing section below.

Design Goals

It tries to mimick as much as possible the official Javascript client library in terms of ease-of-use and in setup process.

Contributing

Submitting a pull request

  • Fork it (https://github.com/nedpals/supabase-go/fork)
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request

Contributors

More Repositories

1

vex

Easy-to-use, modular web framework built for V
V
326
star
2

sharn

Managing shards made easier.
Crystal
39
star
3

vargs

Simple argument parsing library for V.
V
39
star
4

v-jsonrpc

Basic JSON-RPC 2.0-compliant server written on V.
V
32
star
5

tree-sitter-v

Tree-sitter parser for V
C
24
star
6

v-mime

MIME Library for V.
V
22
star
7

jisoni

A native JSON parser written in pure @vlang/v
V
13
star
8

myuic-neo

An unofficial, third-party student portal website for students of the University of the Immaculate Conception (UIC).
Vue
12
star
9

bliss

Experimental code analyzer for V using tree-sitter
TypeScript
10
star
10

lsp.v

Implementation of the Language Server Protocol spec on V for nedpals/vls
V
9
star
11

vls2

V language server rewritten from scratch
V
9
star
12

kuman

Simple, Express-style CLI framework for Node.
TypeScript
9
star
13

intellij-vlang

The soon-to-be-official plugin of V language for IntelliJ
Kotlin
9
star
14

mangavue

Manga reader powered by Vue.
CSS
5
star
15

riz

Static site generator powered by Mithril and Parcel.
JavaScript
4
star
16

m-dex

Library for parsing Mangadex.org data. Written on Crystal.
Crystal
4
star
17

k12-shs-api

API for List of Senior High Schools grabbed from DepEd.
Ruby
3
star
18

sulatcms

Super simple platform-agnostic headless CMS
JavaScript
3
star
19

flames-bot

🔥 Predict your future relationship with other people. For Discord Hack Week 2019.
JavaScript
2
star
20

postgrest-go

Go
2
star
21

ast2

V
1
star
22

pocketwitter

JavaScript
1
star
23

ojt-recorder

TypeScript
1
star
24

errgoengine

Contextualized programming error analysis translation engine
Go
1
star
25

cc131_notes

codes and notes from cc131
Java
1
star