Skip to content

Using SingleProviderRepository with Supabase does not generate adapters #574

@Fabricio-191

Description

@Fabricio-191

Hello, i am currently using brick with Supabase, but i am not yet using the offline first arquitecture (that's for the future me)

For this as the docs says i am using the SingleProviderRepository like this:

class Repository<TModel extends SupabaseModel> extends SingleProviderRepository<TModel> {
  Repository._privateConstructor(super.supabaseProvider);

	SupabaseClient get supabaseClient => Supabase.instance.client;

  static Future<void> init() async {
    await Supabase.initialize(
      url: 'my url obviously',
      anonKey: 'the key to other project obviously',
      postgrestOptions: const PostgrestClientOptions(schema: 'api'),
      storageOptions: const StorageClientOptions(retryAttempts: 1),
    );

    repository = Repository._privateConstructor(
      SupabaseProvider(
        Supabase.instance.client,
        modelDictionary: supabaseModelDictionary,
      ),
    );

    await repository.initialize();
  }
}

And i have two problems, first, when running dart run build_runner build it does not generates adapters for my models and in brick.g.dart the supabaseMappings is empty

I annotated all my models like this:

import 'package:brick_supabase/brick_supabase.dart';

@SupabaseSerializable(tableName: 'activities_ratings')
class ActivityRating extends SupabaseModel {
  ActivityRating({
    required this.userId,
    required this.activityId,
    required this.comment,
    required this.rating,
    required this.createdAt,
    required this.updatedAt,
  });

  final String userId;
  final String activityId;
  final String? comment;
  final int rating;
  //
  final DateTime createdAt;
  final DateTime updatedAt;
}

// this is in a file named:  activity_rating.model.dart

I followed this example, with the difference of the SupabaseSerializable annotation

My second problem is that i am missing a subscribe or subscribeToRealtime method, because SingleProviderRepository only implements delete, get, upsert methods

This is not an error as SingleProviderRepository is generic and subscribeToRealtime is something specific to Supabase, but i would be nice having a SupabaseRepository with a subscribe method

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions