row_row_row 0.1.3
row_row_row: ^0.1.3 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!)
-
Installation:
Option 1: Add as a dependency to your project
dart pub add row_row_rowOption 2: Install globally
dart pub global activate row_row_row
Usage #
Generate Models:
If installed as a dependency:
dart run row_row_row generate [options]
If used locally:
dart run bin/row_row_row.dart generate [options]
If installed globally:
dart pub global run row_row_row generate [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.-c,--clean: Delete all existing generated files before generating new ones.-h,--help: Show usage information, including all options.
Examples:
# Generate models (no formatting)
dart run row_row_row generate
# Generate models and format them
dart run row_row_row generate --dart-format
# Clean existing files and generate new ones
dart run row_row_row generate --clean
# Clean existing files, generate new ones, and format them
dart run row_row_row generate --clean --dart-format
# Show help
dart run row_row_row --help
Acknowledgements #
This project was developed with the assistance of AI.