supapod 1.0.2 copy "supapod: ^1.0.2" to clipboard
supapod: ^1.0.2 copied to clipboard

Seamlessly integrate Supabase into your Serverpod applications.

example/supapod_example.dart

import 'package:serverpod/serverpod.dart';
import 'package:supapod/src/supabase_wrapper.dart';

import 'greeting.dart';
import 'initialize.dart';

class GreetingEndpoint extends Endpoint {
  Future<Greeting> hello(Session session, String name) async {
    final greeting = Greeting(
      message: 'Hello $name',
      author: 'Serverpod',
      timestamp: DateTime.now(),
    );

    // The usual command in serverpod to interact with postgres database
    Greeting.db.insertRow(session, greeting);
    Greeting.db.findFirstRow(session, where: (t) => t.author.equals('John Doe'));

    // supapod command to interact with supabase database
    Supabase.db<Greeting>()?.insertRow(session, greeting);

    // Supapod internally handles the tables and columns as well from the auto-generated code from serverpod
    // so you can expect column names and types to be correct
    Supabase.db<Greeting>()?.findFirstRow(session, where: (t) => (t as GreetingTable).author.equals('John Doe'));

    // with obviously all the goodies that supabase provides like Auth, Realtime, Storage
    Supabase.instance.storage.from('avatars').getPublicUrl('public/avatar1.png');

    return greeting;
  }
}

Future<void> main(List<String> args) async {
  initializeSupabase();

//   final pod = Serverpod(
//     args,
//     Protocol(),
//     Endpoints(),
//   );
//
//   await pod.start();
}
2
likes
150
points
57
downloads

Publisher

verified publisheryashmakan.com

Weekly Downloads

Seamlessly integrate Supabase into your Serverpod applications.

Repository (GitHub)
View/report issues

Topics

#serverpod #supabase #database

Documentation

API reference

License

MIT (license)

Dependencies

serverpod, supabase

More

Packages that depend on supapod