supabase

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 3 Imported by: 0

README

An isomorphic Go client for Supabase.

Features

  • Integration with Supabase.Realtime
    • Realtime listeners for database changes
  • Integration with Postgrest
    • Access your database using a REST API generated from your schema & database functions
  • Integration with Gotrue
    • User authentication, including OAuth, email/password, and native sign-in
  • Integration with Supabase Storage
    • Store files in S3 with additional managed metadata
  • Integration with Supabase Edge Functions
    • Run serverless functions on the edge

Quickstart

  1. To get started, create a new project in the Supabase Admin Panel.
  2. Grab your Supabase URL and Supabase Public Key from the Admin Panel (Settings -> API Keys).
  3. Initialize the client!

Reminder: supabase-go has some APIs that require the service_key rather than the public_key (for instance: the administration of users, bypassing database roles, etc.). If you are using the service_key be sure it is not exposed client side. Additionally, if you need to use both a service account and a public/user account, please do so using a separate client instance for each.

Documentation

Get Started

First of all, you need to install the library:

  go get github.com/supabase-community/supabase-go

Then you can use

  client, err := supabase.NewClient(API_URL, API_KEY, nil)
  if err != nil {
    fmt.Println("cannot initalize client", err)
  }
  data, count, err := client.From("countries").Select("*", "exact", false).Execute()

Documentation

Index

Constants

View Source
const (
	REST_URL      = "/rest/v1"
	STORAGE_URL   = "/storage/v1"
	DefaultSchema = "public"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Rest    *postgrest.Client
	Storage *storage.Client
}

func NewClient

func NewClient(url, key string, options *Options) (*Client, error)

NewClient creates a new Supabase client.

func (*Client) From

func (c *Client) From(table string) *postgrest.QueryBuilder

Wrap postgrest From method

func (*Client) Rpc

func (c *Client) Rpc(name, count string, rpcBody interface{}) string

Wrap postgrest Rpc method

type Options added in v0.0.4

type Options struct {
	Headers map[string]string
	Db      *OptionsDb
}

type OptionsDb added in v0.0.4

type OptionsDb struct {
	Schema string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL