brick_supabase 0.0.1
brick_supabase: ^0.0.1 copied to clipboard
Supabase connector for Brick, a data persistence library. Includes annotations, adapter, model, and provider.
Supabase Provider #
Connecting Brick with Supabase.
Models #
@SupabaseSerializable(tableName:)
#
The Supabase table name must be specified to connect from
, upsert
and delete
invocations:
@SupabaseSerializable(tableName: 'users')
class User
Fields #
@Supabase(unique:)
#
Connect Supabase's primary key (or any other index) to your application code. This is useful for upsert
and delete
logic when mutating instances.
@Supabase(unique: true, name: 'id')
final int supabaseId;
@Supabase(enumAsString:)
#
Brick by default assumes enums from a REST API will be delivered as integers matching the index in the Flutter app. However, if your API delivers strings instead, the field can be easily annotated without writing a custom generator.
Given the API:
{ "user": { "hats": ["bowler", "birthday"] } }
Simply convert hats
into a Dart enum:
enum Hat { baseball, bowler, birthday }
...
@Supabase(enumAsString: true)
final List<Hat> hats;
@Supabase(name:)
#
REST keys can be renamed per field. This will override the default set by SupabaseSerializable#fieldRename
.
@Supabase(
name: "full_name" // "full_name" is used in from and to requests to REST instead of "last_name"
)
final String lastName;
@Supabase(ignoreFrom:)
and @Supabase(ignoreTo:)
#
When true, the field will be ignored by the (de)serializing function in the adapter.
Unsupported Field Types #
The following are not serialized to REST. However, unsupported types can still be accessed in the model as non-final fields.
- Nested
List<>
e.g.<List<List<int>>>
- Many-to-many associations