flutter_orm_m8 0.4.0
flutter_orm_m8: ^0.4.0 copied to clipboard
Flutter package for ORM annotations. It defines ColumnMetadata, DataTable, DataColumn annotations. The main purpose is to be used by code generators to expand annotated models.
Flutter ORM Mate - flutter_orm_m8 #
Flutter package for ORM annotations.
Introduction #
The package adds definitions for a set of types that could be combined to expand ORM capabilities in the annotated code. The current version, defines four annotation types:
- DataTable
- DataColumn
- TableMetadata
- ColumnMetadata
In order to ease the code emitting three abstract classes are defined:
- DbEntity
- DbAccountEntity
- DbAccountRelatedEntity
DataTable #
DataTable describes the required name for the table in conjuction with a bit mask for optional TableMetadata
@DataTable("a01_tests")
class A01Test implements DbAccountRelatedEntity {
DataColumn #
DataColumn describes the required name for the column in conjunction with a bit mask for required ColumnMetadata's
@DataColumn("id", ColumnMetadata.PrimaryKey | ColumnMetadata.Unique | ColumnMetadata.AutoIncrement)
int id;
TableMetadata #
The TableMetadata describes the basic options for the table:
- SoftDeletable
- TrackCreate
- TrackUpdate
The options may be combined in various ways using | operator
@DataTable(
"health_issues",
TableMetadata.SoftDeletable |
TableMetadata.TrackCreate |
TableMetadata.TrackUpdate)
ColumnMetadata #
The ColumnMetadata describes the basic options for a column definition:
- Ignore
- PrimaryKey
- Unique
- NotNull
- AutoIncrement
- Indexed
The options may be combined in various ways using | operator
@DataColumn("id", ColumnMetadata.PrimaryKey | ColumnMetadata.Unique | ColumnMetadata.AutoIncrement)
Usage #
The package can be a start for other projects that aim to develop an ORM. Such project is https://github.com/matei-tm/flutter-sqlite-m8-generator
@DataTable("a01_tests", TableMetadata.SoftDeletable)
class A01Test implements DbAccountRelatedEntity {
@DataColumn("id", ColumnMetadata.PrimaryKey | ColumnMetadata.Unique | ColumnMetadata.AutoIncrement)
int id;
@DataColumn("account_id")
int accountId;
@DataColumn("record_date")
int recordDate;
}