Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README with ignore annotation, positional and named parameters #249

Merged
merged 1 commit into from
Jan 25, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This package is still in an early phase and the API will likely change.
1. [Migrations](#migrations)
1. [In-Memory Database](#in-memory-database)
1. [Callback](#callback)
1. [Ignore Fields](#ignore-fields)
1. [Examples](#examples)
1. [Naming](#naming)
1. [Bugs and Feedback](#bugs-and-feedback)
Expand Down Expand Up @@ -305,6 +306,11 @@ 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`.

`@ignore` excludes annotated fields from the library's mapping.
More information on that can be found in the [Ignore Fields](#ignore-fields) section.

Constructors with positional and named parameters are supported out of the box.

```dart
@Entity(tableName: 'person')
class Person {
Expand Down Expand Up @@ -456,6 +462,24 @@ final database = await $FloorAppDatabase
.build();
```

## Ignore Fields
The `hashCode` property and all static fields of entities are ignored by default and thus excluded from the library's mapping.
In case further fields should be ignored, the `@ignore` annotation should be used and applied as shown in the following snippet.

```dart
class Person {
@primaryKey
final int id;

final String name;

@ignore
String nickname;

Person(this.id, this.name);
}
```

## Examples
For further examples take a look at the [example](https://github.com/vitusortner/floor/tree/develop/example) and [floor_test](https://github.com/vitusortner/floor/tree/develop/floor_test) directories.

Expand Down