supabase_rs 0.3.0

Lightweight Rust client for Supabase REST and GraphQL
Documentation

supabase_rs

supabase_rs is an extremely light weight Supabase SDK for interacting with it's database.

I'm actively covering the entire Supabase API including Auth, Realtime, Storage etc

Feature flags

  • nightly: Enables the GraphQL module to interact without REST.
  • storage: Enables the Storage module to interact with Supabase Storage.

Nightly build

If you want to use GraphQL early you can enable the nightly flag, this is NOT production ready obviously.

  • Note GraphQL and REST can be used together as the Client is shared from wherever it was authenticated initially.

Database Features

  • Updating
  • Inserting
  • Inserting if unique
  • Bulk Inserting
  • Upserting
  • Bulk Upserting
  • Delete (only per ID)
  • Select
  • Applying Filters
  • Counting total records

Advanced Filtering over select()

  • Column is equal to a value
  • Column is not equal to a value
  • Column is greater than a value
  • Column is less than a value
  • Column is greater than or equal to a value
  • Column is less than or equal to a value
  • Order the results
  • Limit the number of rows returned
  • Retrieve as a CSV

Storage

  • Downloading a file from a public bucket
  • Saving a file
  • Saving a file to a private bucket
  • Uploading a file
  • Generating a signed url
  • Deleting a file

GraphQL

  • Query validation
  • Calling a Query
  • Calling a mutating Query
  • Response parsing

Auth

// coming soon //

Realtime

// coming soon //

Supabase SDK for Rust

This is an unofficial Rust SDK for Supabase, since there is no official SDK for Rust yet.

Features

  • Insert: Add new rows to a table.
  • Insert if unique: Add a new row only if it does not violate a UNIQUE constraint.
  • Update: Modify existing rows in a table based on a unique identifier.
  • Select: Insert a new row into a table if it does not exist, or update it if it does.
  • Select with count: Select rows from a table and count the number of rows that match the filter criteria.
  • Select with filter: Select rows from a table based on a filter criteria.
  • Select with filter and count: Select rows from a table based on a filter criteria and count the number of rows that match the filter criteria.
  • Delete: Delete a row from a table based on a unique identifier.

Graphql features

Feature flags

  • storage: Enables the Storage module to interact with Supabase Storage.

Cargo.toml

[dependencies]
supabase-rs = "0.3.0"

// With the [storage] feature
supabase-rs = { version = "0.3.0", features = ["storage"] }

//!

Usage

First make sure you have initialized the Supabase Client Initalizing the SupabaseClient //!

Authentication

The Supabase Client is initialized with the Supabase URL and the Supabase Key. Which are environment variables that can be set in a .env file under the following names or any other

SUPABASE_URL=
SUPABASE_KEY=

Examples

Initialize the Supabase Client

use supabase_rs::SupabaseClient;

use dotenv::dotenv;
use std::env::var;

async fn initialize_supabase_client() -> SupabaseClient {
   dotenv().ok(); // Load the .env file

   let supabase_client: SupabaseClient = SupabaseClient::new(
       var("SUPABASE_URL").unwrap(),
       var("SUPABASE_KEY").unwrap()
       );

   supabase_client
}

This will initialize the Supabase Client with the Supabase URL and the Supabase Key, and return the Supabase Client to be passed to other methods.

More examples will be present in the docs