supabase_extensions 0.5.1 supabase_extensions: ^0.5.1 copied to clipboard
Extensions for the Supabase client that allows faster develeopment
supabase_extensions #
supabase_extensions is an extension library to the Supabase API
Features #
- Using SQL statement strings to get results from Supabase (uses PostgREST behind the scenes)
- Shorter syntax
Note: Select/Insert statement only (WIP)
Getting started #
For using it on your app:
import 'package:supabase_extensions/base.dart';
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;
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
Supabase.on(String table, String eventType) #
// init Supabase Client..
// final supabase = SupabaseClient('supabaseUrl', 'supabaseKey');
// Regular way
supabase.from('test').stream(primaryKey: ['id']).listen((event) {
print(event);
});
You can listen to only single event type ('INSERT'
,'UPDATE'
or 'DELETE'
)
supabase.on('test', 'INSERT').listen((event) {
print(event);
});
// 2nd sytax
supabasr.onInsert('test').listen((event) {
print(event);
});
Remember to remove the channels and to close streams when you're done
supabase.removeAllChannels();
supabase.closeAllStreams(); // ADD THIS TOO!
Additional information #
Based heavily on the Postgrest API