Skip to content

docs(cloud_firestore_odm_generator): ODM now need create_per_field_to_json: true #11728

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

Merged
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
9 changes: 5 additions & 4 deletions packages/cloud_firestore_odm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ flutter pub add --dev cloud_firestore_odm_generator
flutter pub add --dev json_serializable
```

## 5. Enable `create_field_map` of `json_serializable`
## 5. Enable `create_field_map` and `create_per_field_to_json` of `json_serializable`


For the ODM to work, it is necessary to enable the `create_field_map` of `json_serializable`.
For the ODM to work, it is necessary to enable the `create_field_map` and `create_per_field_to_json` of `json_serializable`.
This can be done by creating a `build.yaml` file next to your `pubspec.yaml` and
paste the following:

Expand All @@ -88,15 +88,16 @@ targets:
json_serializable:
options:
create_field_map: true
create_per_field_to_json: true
```


This will enable `create_field_map` for the entire project.
This will enable `create_field_map` and `create_per_field_to_json` for the entire project.

Alternatively, you can enable the option on a per-model basis using `json_annotation`'s `@JsonSerializable` object:

```dart
@JsonSerializable(createFieldMap: true)
@JsonSerializable(createFieldMap: true, createPerFieldToJson: true)
@Collection<Model>(...)
class MyModel {...}
```
Expand Down