admin管理员组

文章数量:1287858

I have a states db and a cities table in my Supabase db. The relationship between them is as you would expect - state_id in the cities db is mapped to states.id as a foreign key. So one state can have multiple cities, and each city has to have a parent state.

I am using this code to get the stream:

  static final streamProvider =
      StreamProvider.autoDispose.family<List<City>, int>(
    (ref, stateId) {
      var streamBuilder = supabase
          .from('cities')
          .stream(primaryKey: ['id']).eq('state_id', stateId);
      var stream = streamBuilder
          .map((data) => data.map((json) => City.fromMap(json)).toList());
      return stream;
    },
  );

I am using this in my ConsumerState widget using:

final citiesAsync = ref.watch(SupabaseDB.streamProvider(_parentState.id));

I have enabled realtime on the cities table and on the states table on the Supabase dashboard. This code works fine when a new city is created or an existing city updated - I get the changes reflected on the respective ConsumerState widget right away. However, deleting cities does not reflect in my widget.

What am I missing?

本文标签: Delete events not captured by Riverpod streamprovider family with SupabaseStack Overflow