row_row_row 0.1.0
row_row_row: ^0.1.0 copied to clipboard
A command-line tool to generate Dart models for Supabase table rows based on the OpenAPI spec.
row_row_row 🚣 #
Generate Dart models for your Supabase table rows instantly!
Tired of writing boilerplate Dart classes for your Supabase tables? row_row_row fetches your database schema and automatically generates .row.dart model files based on your table structure.
Features #
- Connects securely using your Supabase URL and Service Role Key.
- Introspects your schema via Supabase's generated OpenAPI specification.
- Generates clean Dart classes (
YourTable**Row**) with type-safe fields (camelCase). - Includes a
fromJsonfactory constructor for easy data parsing. - Adds a static
fieldrecord mapping Dart fields back to original database column names. - Outputs a handy schema report (
.txt) for reference.
Setup #
-
Environment:
- Ensure you have the Dart SDK installed.
- Create a
.envfile in the project root with your Supabase credentials:
(Important: AddSUPABASE_URL=https://<your-project-ref>.supabase.co SERVICE_ROLE=<your-supabase-service-role-key>.envto your.gitignoreto keep your key safe!)
-
Dependencies:
dart pub get
Usage #
Generate Models:
dart run bin/row_row_row.dart list-tables-views [options]
This command will:
- Fetch the schema from your Supabase project.
- Generate
.row.dartmodel files inlib/row_row_row_generated/tables/. - Create a schema report in
lib/row_row_row_generated/db_schema_report/.
Options:
-f,--dart-format: Automatically format the generated Dart files usingdart format.-h,--help: Show usage information, including all options.
Examples:
# Generate models (no formatting)
dart run bin/row_row_row.dart list-tables-views
# Generate models and format them
dart run bin/row_row_row.dart list-tables-views --dart-format
# Show help
dart run bin/row_row_row.dart --help
Acknowledgements #
This project was developed with the assistance of AI.