diff --git a/floor/CHANGELOG.md b/floor/CHANGELOG.md index aaac13ed..c5d3fabf 100644 --- a/floor/CHANGELOG.md +++ b/floor/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +# 0.13.0 + +### 🚀 Features + +* Support embedded objects + # 0.12.0 ### Changes diff --git a/floor/README.md b/floor/README.md index e9b119ea..5774bf80 100644 --- a/floor/README.md +++ b/floor/README.md @@ -197,6 +197,9 @@ For more information about primary keys and especially compound primary keys, re `@ColumnInfo` enables custom mapping of single table columns. With the annotation, it's possible to give columns a custom name and define if the column is able to store `null`. +`@Embedded` includes annotationed class fields to be embedded to SQL query as if they are fields but from another class. +You can specifies a `prefix` to prepend the column names of the fields in the embedded fields. + #### Limitations - Floor automatically uses the **first** constructor defined in the entity class for creating in-memory objects from database rows. - There needs to be a constructor. @@ -210,7 +213,16 @@ class Person { @ColumnInfo(name: 'custom_name', nullable: false) final String name; - Person(this.id, this.name); + @Embedded(prefix: 'custom_prefix') + final Address address; + + Person(this.id, this.name, this.address); +} + +class Address { + final String street; + + Address(this.street); } ``` diff --git a/floor/pubspec.yaml b/floor/pubspec.yaml index ccf62078..da57633a 100644 --- a/floor/pubspec.yaml +++ b/floor/pubspec.yaml @@ -2,7 +2,7 @@ name: floor description: > A supportive SQLite abstraction for your Flutter applications. This library is the runtime dependency. -version: 0.12.0 +version: 0.13.0 homepage: https://github.com/vitusortner/floor author: Vitus Ortner <vitusortner.dev@gmail.com>