Closed carlomigueldy closed 2 years ago
Should also be possible to implement this in a way that mirrors the supabase javascript API. We could pass the type in on the .from
method and check to see if it inherits from a supabase abstract data type which requires fromJson/toJson methods. It's definitely not as flexible as the firebase implementation so that may still be better. Just suggesting it depending on how important it is that this library keeps in line with the official supabase documentation.
you can create an extension for this:
ex:
typedef FromSupabase<T> = T Function(
dynamic data,
PostgrestError error,
);
extension Converter<T> on Future<PostgrestResponse> {
Future<T> withConverter<T>({
FromSupabase<T> fromResponse,
}) async {
final data = await this;
return fromResponse.call(data.data, data.error);
}
}
not tested and was written entirely in my imagination.
Feature request
Is your feature request related to a problem? Please describe.
Yeah sort of, this would refer to be as "boilerplate" code. Since we typically do that manually every time we fetch data.
Describe the solution you'd like
Firestore has implemented this feature. So I'll just link up that from pub.dev changelog.
https://pub.dev/packages/cloud_firestore/changelog#200
Additional context