Stormberry is an strongly-typed ORM-like code-generation package to provide easy bindings between your dart classes and postgres database. It supports all kinds of relations without any complex configuration.
This package is still in active development. If you have any feedback or feature requests, write me and issue on github.
- Action constructor parameters
- Query constructor parameters
- Improve Readme
- Improve example
- Testing & Maintenance
- Improve code structure
- Write tests
- Long Term
- Be database agnostic (sub-packages)
To get started import
stormberry and run the code-generation.
You also have to annotate your classes used as database tables.
You specify your database configuration by annotating some dart classes
@Table() annotation is the main point for your configuration.
For each table you can define a series of
Views, which you can query for. A view is a subset of fields of the table and resolved relations.
When you have two-way relations in your models, with
Views you have to make sure not to have any cyclic relations.
You specify the modified fields of the a
View using the
@Field annotation, more specific one of its three constructors.
@Field.hidden()hides a specific field from the table
@Field.view()specifies which view to use for this field (which has to be a relation to another table)
@Field.filtered()specifies a filter (where clause) on this field (TODO)
For querying a table or view, set a
Query to your table.
For each query you will have a custom
query() method to call on your table.
Most of the time you will want to use the default
When wanting to query a view, use the
You can specify a custom query with custom sql by extending the
Query<T, U> class.
You will then need to implement the
Future<T> apply(Database db, U params) method.
You can specify
Actions to perform on your table.
Similar to the queries, for each action a custom
doAction() method is generated for you to use later.
Again you can choose from the default
Actions or write a custom class.
The available default actions are
SingleDeleteAction as well as their
As an advanced configuration you can specify indexes on your table using the
Database migration tool
Stormberry comes with a database migration tool, to create or update the schema of your database.
To use this run the following command from the root folder of your project.
flutter pub run stormberry
In order to connect to your database, provide the following environment variables: