stream method

Stream<List<R>> stream({
  1. SupaStreamFilter<B>? filter,
  2. SupaStreamModifier<B, R>? modifier,
})

Streams records from the Supabase table.

filter: The filter to apply to the query.

modifier: The modifier to apply to the query.

Implementation

Stream<List<R>> stream({
  SupaStreamFilter<B>? filter,
  SupaStreamModifier<B, R>? modifier,
}) {
  final request = supabaseClient
      .schema(schema)
      .from(tableName)
      .stream(primaryKey: primaryKey);

  if (filter != null) {
    if (modifier != null) {
      return request
          .supaApplyFilter(filter)
          .supaApplyModifier(modifier)
          .map((list) => list.map(recordFromJSON).toList());
    } else {
      return request.supaApplyFilter(filter).map((list) {
        return list.map(recordFromJSON).toList();
      });
    }
  }

  if (modifier != null) {
    return request
        .supaApplyModifier(modifier)
        .map((list) => list.map(recordFromJSON).toList());
  }

  return request.map((list) => list.map(recordFromJSON).toList());
}