supabase_extensions

Creator: coderz1093

Last updated:

0 purchases

supabase_extensions Image
supabase_extensions Images

Languages

Categories

Add to Cart

Description:

supabase extensions

supabase_extensions #
supabase_extensions is a couple of extensions to the Supabase API
Features #

Using SQL statement strings to get results from Supabase (uses PostgREST behind the scenes)
Shorter syntax when possible
Simpler way to listen to changes in the Database

Note: only Select/Insert SQL statement are supported (WIP)
Getting started #
For using it on your app:
import 'package:supabase_extensions/base.dart';
copied to clipboard
For API reference check here
Usage #
SupabaseClient.sql(String rawQuery) #
Fetching data using raw queries' strings using Supabase's database (Postgres)
// init Supabase Client..
// final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');

const sqlString = 'SELECT code FROM courses WHERE code > 32000 ORDER BY code LIMIT 2';
QueryResults queryResults = await supabase.sql(sqlString);

List<Map<String, dynamic>> rows = queryResults.rows;
copied to clipboard
SupabaseClient.uid #
Get the user's ID (if exist) easily
// init Supabase Client..
// final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');

String? userId = supabase.uid; /// instead supabase.auth.currentUser?.id
copied to clipboard
Supabase.isLogged #
Get if the user already logged in or not
// init Supabase Client..
// final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');

bool isLoggedIn = supabase.isLogged; /// instead supabase.auth.currentUser?.id != null
copied to clipboard
Supabase.jwt #
Get the user's current session access token (if the user already logged in)
// init Supabase Client..
// final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');

String? accessToken = supabase.jwt; /// instead supabase.auth.currentSession?.accessToken
copied to clipboard
Supabase.on(String table, CrudEvent eventType) #
// init Supabase Client..
// final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');

// Regular way
supabase.from('test').stream(primaryKey: ['id']).listen((event) {
print(event);
});
copied to clipboard
You can listen to only single event type ('INSERT','UPDATE' or 'DELETE')
// any event in table 'test'
supabase.on('table').listen((event) {
print(event);
});

// only INSERT events in table 'test'
supabase.on('table', CrudEvent.insert).listen((event) {
print(event);
});

// shorter syntax for only INSERT, DELETE
supabase.onInsert('table').listen((event) {
print(event);
});
supabase.onDelete('table').listen((event) {
print(event);
});
copied to clipboard
!! Remember to remove the channels and to close streams when you're done
supabase.removeAllChannels();
supabase.closeAllStreams(); // ADD THIS TOO!
copied to clipboard
SupabaseAuth extensions #
auth.provider()
Return the name of the provider the user is logged to ('apple', 'google'..)
String? providerName = supabase.auth.provider; /// instead supabase.auth.provider
copied to clipboard
Additional information #
Based heavily on the Postgrest API

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.