diff --git a/packages/cloud_firestore_odm/CHANGELOG.md b/packages/cloud_firestore_odm/CHANGELOG.md index 7bf251c..72904e1 100644 --- a/packages/cloud_firestore_odm/CHANGELOG.md +++ b/packages/cloud_firestore_odm/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased build + +- **FEAT**: Add batch API ([#12](https://github.com/FirebaseExtended/firestoreodm-flutter/issues/12)). ([4dd8a9a8](https://github.com/FirebaseExtended/firestoreodm-flutter/commit/4dd8a9a893bf6ababa5e9d52de95bacc549ad21b)) + ## 1.0.0-dev.86 - 2024-06-09 - Bumped minimum cloud_firestore version to `5.0.0` @@ -12,336 +16,336 @@ ## 1.0.0-dev.82 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.81 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.80 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.79 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.78 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.77 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.76 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.75 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.74 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.73 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.72 - - **FIX**: Fix ODM not working with latest Freezed ([#11753](https://github.com/firebase/flutterfire/issues/11753)). ([0578182d](https://github.com/firebase/flutterfire/commit/0578182d4f0ddbb855f036771b971ef24d942157)) +- **FIX**: Fix ODM not working with latest Freezed ([#11753](https://github.com/firebase/flutterfire/issues/11753)). ([0578182d](https://github.com/firebase/flutterfire/commit/0578182d4f0ddbb855f036771b971ef24d942157)) ## 1.0.0-dev.71 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.70 - - **FEAT**(cloud_firestore_odm_generator): Support all serializable types ([#11365](https://github.com/firebase/flutterfire/issues/11365)). ([f4c21f83](https://github.com/firebase/flutterfire/commit/f4c21f834569bb363c80af583b53164f7cbd5ada)) +- **FEAT**(cloud_firestore_odm_generator): Support all serializable types ([#11365](https://github.com/firebase/flutterfire/issues/11365)). ([f4c21f83](https://github.com/firebase/flutterfire/commit/f4c21f834569bb363c80af583b53164f7cbd5ada)) ## 1.0.0-dev.69 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.68 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.67 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.66 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.65 - - **FEAT**(cloud_firestore_odm_generator): Support Sets as well as Lists for query method generation ([#11361](https://github.com/firebase/flutterfire/issues/11361)). ([d60cfe63](https://github.com/firebase/flutterfire/commit/d60cfe63a42d0a960ef241a2c062d880a3df17ec)) +- **FEAT**(cloud_firestore_odm_generator): Support Sets as well as Lists for query method generation ([#11361](https://github.com/firebase/flutterfire/issues/11361)). ([d60cfe63](https://github.com/firebase/flutterfire/commit/d60cfe63a42d0a960ef241a2c062d880a3df17ec)) ## 1.0.0-dev.64 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.63 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.62 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.61 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.60 - - **FIX**: typo in build.yaml ([#11027](https://github.com/firebase/flutterfire/issues/11027)). ([f9cdcfea](https://github.com/firebase/flutterfire/commit/f9cdcfea96b33a02401c4ea3ed2c69b513e573ea)) - - **DOCS**(firestore): improve wording of what `set()` API does ([#11038](https://github.com/firebase/flutterfire/issues/11038)). ([883cbff9](https://github.com/firebase/flutterfire/commit/883cbff92f1245d7e96b7f845e3f363d8dbb0441)) +- **FIX**: typo in build.yaml ([#11027](https://github.com/firebase/flutterfire/issues/11027)). ([f9cdcfea](https://github.com/firebase/flutterfire/commit/f9cdcfea96b33a02401c4ea3ed2c69b513e573ea)) +- **DOCS**(firestore): improve wording of what `set()` API does ([#11038](https://github.com/firebase/flutterfire/issues/11038)). ([883cbff9](https://github.com/firebase/flutterfire/commit/883cbff92f1245d7e96b7f845e3f363d8dbb0441)) ## 1.0.0-dev.59 - - **FIX**(odm_generator): update deprecated check `isDynamic` ([#10937](https://github.com/firebase/flutterfire/issues/10937)). ([bb9c5523](https://github.com/firebase/flutterfire/commit/bb9c5523964d9e11a82f80ceb74d808808cc2a4c)) +- **FIX**(odm_generator): update deprecated check `isDynamic` ([#10937](https://github.com/firebase/flutterfire/issues/10937)). ([bb9c5523](https://github.com/firebase/flutterfire/commit/bb9c5523964d9e11a82f80ceb74d808808cc2a4c)) ## 1.0.0-dev.58 - - **FEAT**: update dependency constraints to `sdk: '>=2.18.0 <4.0.0'` `flutter: '>=3.3.0'` ([#10946](https://github.com/firebase/flutterfire/issues/10946)). ([2772d10f](https://github.com/firebase/flutterfire/commit/2772d10fe510dcc28ec2d37a26b266c935699fa6)) +- **FEAT**: update dependency constraints to `sdk: '>=2.18.0 <4.0.0'` `flutter: '>=3.3.0'` ([#10946](https://github.com/firebase/flutterfire/issues/10946)). ([2772d10f](https://github.com/firebase/flutterfire/commit/2772d10fe510dcc28ec2d37a26b266c935699fa6)) ## 1.0.0-dev.57 - - **FEAT**: upgrade to dart 3 compatible dependencies ([#10890](https://github.com/firebase/flutterfire/issues/10890)). ([4bd7e59b](https://github.com/firebase/flutterfire/commit/4bd7e59b1f2b09a2230c49830159342dd4592041)) +- **FEAT**: upgrade to dart 3 compatible dependencies ([#10890](https://github.com/firebase/flutterfire/issues/10890)). ([4bd7e59b](https://github.com/firebase/flutterfire/commit/4bd7e59b1f2b09a2230c49830159342dd4592041)) ## 1.0.0-dev.56 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.55 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.54 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.53 - - **FEAT**: bump dart sdk constraint to 2.18 ([#10618](https://github.com/firebase/flutterfire/issues/10618)). ([f80948a2](https://github.com/firebase/flutterfire/commit/f80948a28b62eead358bdb900d5a0dfb97cebb33)) +- **FEAT**: bump dart sdk constraint to 2.18 ([#10618](https://github.com/firebase/flutterfire/issues/10618)). ([f80948a2](https://github.com/firebase/flutterfire/commit/f80948a28b62eead358bdb900d5a0dfb97cebb33)) ## 1.0.0-dev.52 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.51 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.50 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.49 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.48 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.47 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.46 - - **REFACTOR**: upgrade project to remove warnings from Flutter 3.7 ([#10344](https://github.com/firebase/flutterfire/issues/10344)). ([e0087c84](https://github.com/firebase/flutterfire/commit/e0087c845c7526c11a4241a26d39d4673b0ad29d)) +- **REFACTOR**: upgrade project to remove warnings from Flutter 3.7 ([#10344](https://github.com/firebase/flutterfire/issues/10344)). ([e0087c84](https://github.com/firebase/flutterfire/commit/e0087c845c7526c11a4241a26d39d4673b0ad29d)) ## 1.0.0-dev.45 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.44 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.43 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.42 - - **FIX**: a bug where the ODM does not respect JSON case renaming ([#9988](https://github.com/firebase/flutterfire/issues/9988)). ([02d394b6](https://github.com/firebase/flutterfire/commit/02d394b6b0917f7dc98711b9939630c0b423ed63)) +- **FIX**: a bug where the ODM does not respect JSON case renaming ([#9988](https://github.com/firebase/flutterfire/issues/9988)). ([02d394b6](https://github.com/firebase/flutterfire/commit/02d394b6b0917f7dc98711b9939630c0b423ed63)) ## 1.0.0-dev.41 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.40 - - **FIX**: Improve error handling if a collection and the associated model are defined in separate files. ([#9827](https://github.com/firebase/flutterfire/issues/9827)). ([294e1085](https://github.com/firebase/flutterfire/commit/294e1085ae7af92573657489b78ae0a82ab5e4b4)) +- **FIX**: Improve error handling if a collection and the associated model are defined in separate files. ([#9827](https://github.com/firebase/flutterfire/issues/9827)). ([294e1085](https://github.com/firebase/flutterfire/commit/294e1085ae7af92573657489b78ae0a82ab5e4b4)) ## 1.0.0-dev.39 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.38 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.37 - - **FIX**: The ODM correctly no-longer generates query utilities for getters. ([#9766](https://github.com/firebase/flutterfire/issues/9766)). ([cfb56939](https://github.com/firebase/flutterfire/commit/cfb569395cadf6b7bcd8727b680d0b52e4e9297d)) +- **FIX**: The ODM correctly no-longer generates query utilities for getters. ([#9766](https://github.com/firebase/flutterfire/issues/9766)). ([cfb56939](https://github.com/firebase/flutterfire/commit/cfb569395cadf6b7bcd8727b680d0b52e4e9297d)) ## 1.0.0-dev.36 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.35 - - **FEAT**: Add support for FirebaseFirestore.myNamedQueryGet() ([#9721](https://github.com/firebase/flutterfire/issues/9721)). ([82152a00](https://github.com/firebase/flutterfire/commit/82152a0081343a6f7b7d1f5725818825e2b1191a)) +- **FEAT**: Add support for FirebaseFirestore.myNamedQueryGet() ([#9721](https://github.com/firebase/flutterfire/issues/9721)). ([82152a00](https://github.com/firebase/flutterfire/commit/82152a0081343a6f7b7d1f5725818825e2b1191a)) ## 1.0.0-dev.34 - - **FEAT**: Add support for FieldValue ([#9684](https://github.com/firebase/flutterfire/issues/9684)). ([467c403a](https://github.com/firebase/flutterfire/commit/467c403aad5dc9a829450eee22750e172e88f90b)) +- **FEAT**: Add support for FieldValue ([#9684](https://github.com/firebase/flutterfire/issues/9684)). ([467c403a](https://github.com/firebase/flutterfire/commit/467c403aad5dc9a829450eee22750e172e88f90b)) ## 1.0.0-dev.33 - - **FIX**: Update ignored lints in generated files ([#9683](https://github.com/firebase/flutterfire/issues/9683)). ([3ab283bb](https://github.com/firebase/flutterfire/commit/3ab283bb3ec6e5dbc0befefb062c5069959f9fb5)) - - **FEAT**: Add transaction utilities to the ODM ([#9670](https://github.com/firebase/flutterfire/issues/9670)). ([7d84d70a](https://github.com/firebase/flutterfire/commit/7d84d70a1120f7751f5ff817d7b10b330dcf7e06)) +- **FIX**: Update ignored lints in generated files ([#9683](https://github.com/firebase/flutterfire/issues/9683)). ([3ab283bb](https://github.com/firebase/flutterfire/commit/3ab283bb3ec6e5dbc0befefb062c5069959f9fb5)) +- **FEAT**: Add transaction utilities to the ODM ([#9670](https://github.com/firebase/flutterfire/issues/9670)). ([7d84d70a](https://github.com/firebase/flutterfire/commit/7d84d70a1120f7751f5ff817d7b10b330dcf7e06)) ## 1.0.0-dev.32 - - **FEAT**: Allow injecting the document ID in the ODM model ([#9600](https://github.com/firebase/flutterfire/issues/9600)). ([c7e93cfe](https://github.com/firebase/flutterfire/commit/c7e93cfec14e0e00bcabb232760ae5a968a1c2a1)) +- **FEAT**: Allow injecting the document ID in the ODM model ([#9600](https://github.com/firebase/flutterfire/issues/9600)). ([c7e93cfe](https://github.com/firebase/flutterfire/commit/c7e93cfec14e0e00bcabb232760ae5a968a1c2a1)) ## 1.0.0-dev.31 - - **FIX**: handle query.orderBy(startAt:).orderBy() ([#9185](https://github.com/firebase/flutterfire/issues/9185)). ([62396e8a](https://github.com/firebase/flutterfire/commit/62396e8a4a229dfc096d6280964bb559c00b3511)) +- **FIX**: handle query.orderBy(startAt:).orderBy() ([#9185](https://github.com/firebase/flutterfire/issues/9185)). ([62396e8a](https://github.com/firebase/flutterfire/commit/62396e8a4a229dfc096d6280964bb559c00b3511)) ## 1.0.0-dev.30 - - **FEAT**: add support for specifying class name prefix ([#9453](https://github.com/firebase/flutterfire/issues/9453)). ([49921a43](https://github.com/firebase/flutterfire/commit/49921a4362c5965d2efeed17eb73775302007ea8)) +- **FEAT**: add support for specifying class name prefix ([#9453](https://github.com/firebase/flutterfire/issues/9453)). ([49921a43](https://github.com/firebase/flutterfire/commit/49921a4362c5965d2efeed17eb73775302007ea8)) ## 1.0.0-dev.29 - - **FEAT**: Add support using Freezed classes as collection models ([#9483](https://github.com/firebase/flutterfire/issues/9483)). ([ce238f71](https://github.com/firebase/flutterfire/commit/ce238f713b250f523890b9e7e42d395f433ed80f)) +- **FEAT**: Add support using Freezed classes as collection models ([#9483](https://github.com/firebase/flutterfire/issues/9483)). ([ce238f71](https://github.com/firebase/flutterfire/commit/ce238f713b250f523890b9e7e42d395f433ed80f)) ## 1.0.0-dev.28 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.27 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.26 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.25 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.24 > Note: This release has breaking changes. - - **FIX**: Correctly type `firestoreJsonConverters` as `List` instead of `List` ([#9236](https://github.com/firebase/flutterfire/issues/9236)). ([b39d87c7](https://github.com/firebase/flutterfire/commit/b39d87c7d62cc8bbaddc0b151ec987ee54706870)) - - **FEAT**: Add where(arrayContains) support ([#9167](https://github.com/firebase/flutterfire/issues/9167)). ([1a2f2262](https://github.com/firebase/flutterfire/commit/1a2f2262578c6230560761630d017637b99cbd6c)) - - **BREAKING** **FEAT**: The low-level interface of Queries/Document ([#9184](https://github.com/firebase/flutterfire/issues/9184)). ([fad4b0cd](https://github.com/firebase/flutterfire/commit/fad4b0cd0aa09e9161c64deeecf222c14603cd69)) +- **FIX**: Correctly type `firestoreJsonConverters` as `List` instead of `List` ([#9236](https://github.com/firebase/flutterfire/issues/9236)). ([b39d87c7](https://github.com/firebase/flutterfire/commit/b39d87c7d62cc8bbaddc0b151ec987ee54706870)) +- **FEAT**: Add where(arrayContains) support ([#9167](https://github.com/firebase/flutterfire/issues/9167)). ([1a2f2262](https://github.com/firebase/flutterfire/commit/1a2f2262578c6230560761630d017637b99cbd6c)) +- **BREAKING** **FEAT**: The low-level interface of Queries/Document ([#9184](https://github.com/firebase/flutterfire/issues/9184)). ([fad4b0cd](https://github.com/firebase/flutterfire/commit/fad4b0cd0aa09e9161c64deeecf222c14603cd69)) ## 1.0.0-dev.23 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.22 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.21 - - **FEAT**: add orderByFieldPath / whereFieldPath ([#8951](https://github.com/firebase/flutterfire/issues/8951)). ([5957c23b](https://github.com/firebase/flutterfire/commit/5957c23b44b235dab9d97449acb9c737da07b8e7)) - - **FEAT**: Add support for DateTime/Timestamp/GeoPoint ([#8563](https://github.com/firebase/flutterfire/issues/8563)). ([f2ea3696](https://github.com/firebase/flutterfire/commit/f2ea36964662d396dbc26bd931bb2662a5898168)) - - **FEAT**: add support for json_serializable's field rename/property ignore ([#9030](https://github.com/firebase/flutterfire/issues/9030)). ([81ec08fd](https://github.com/firebase/flutterfire/commit/81ec08fd64d57b4fbdc8e4fca39b5ab84dcc8669)) +- **FEAT**: add orderByFieldPath / whereFieldPath ([#8951](https://github.com/firebase/flutterfire/issues/8951)). ([5957c23b](https://github.com/firebase/flutterfire/commit/5957c23b44b235dab9d97449acb9c737da07b8e7)) +- **FEAT**: Add support for DateTime/Timestamp/GeoPoint ([#8563](https://github.com/firebase/flutterfire/issues/8563)). ([f2ea3696](https://github.com/firebase/flutterfire/commit/f2ea36964662d396dbc26bd931bb2662a5898168)) +- **FEAT**: add support for json_serializable's field rename/property ignore ([#9030](https://github.com/firebase/flutterfire/issues/9030)). ([81ec08fd](https://github.com/firebase/flutterfire/commit/81ec08fd64d57b4fbdc8e4fca39b5ab84dcc8669)) ## 1.0.0-dev.20 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.19 - - **FEAT**: add whereDocumentId/orderByDocumentId (#8935). ([3769bcca](https://github.com/firebase/flutterfire/commit/3769bccadedc2c12228ec51dfb48561a23055370)) +- **FEAT**: add whereDocumentId/orderByDocumentId (#8935). ([3769bcca](https://github.com/firebase/flutterfire/commit/3769bccadedc2c12228ec51dfb48561a23055370)) ## 1.0.0-dev.18 - - **REFACTOR**: use "firebase" instead of "FirebaseExtended" as organisation in all links for this repository (#8791). ([d90b8357](https://github.com/firebase/flutterfire/commit/d90b8357db01d65e753021358668f0b129713e6b)) +- **REFACTOR**: use "firebase" instead of "FirebaseExtended" as organisation in all links for this repository (#8791). ([d90b8357](https://github.com/firebase/flutterfire/commit/d90b8357db01d65e753021358668f0b129713e6b)) ## 1.0.0-dev.17 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.16 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.15 - - **FEAT**: Assert that collection.doc(id) does not point to a separate collection ([#8676](https://github.com/firebase/flutterfire/issues/8676)). ([0808205b](https://github.com/firebase/flutterfire/commit/0808205bdca03fc913015f00f5ffc2e1d018adb9)) +- **FEAT**: Assert that collection.doc(id) does not point to a separate collection ([#8676](https://github.com/firebase/flutterfire/issues/8676)). ([0808205b](https://github.com/firebase/flutterfire/commit/0808205bdca03fc913015f00f5ffc2e1d018adb9)) ## 1.0.0-dev.14 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.13 - - **FEAT**: upgrade analyzer, freezed_annotation and json_serializable dependencies (#8465). ([8a27ab21](https://github.com/firebase/flutterfire/commit/8a27ab21279d72998e80aa17b8ec39a9e4a08ec8)) +- **FEAT**: upgrade analyzer, freezed_annotation and json_serializable dependencies (#8465). ([8a27ab21](https://github.com/firebase/flutterfire/commit/8a27ab21279d72998e80aa17b8ec39a9e4a08ec8)) ## 1.0.0-dev.12 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.11 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.10 - - **FIX**: update all Dart SDK version constraints to Dart >= 2.16.0 (#8184). ([df4a5bab](https://github.com/firebase/flutterfire/commit/df4a5bab3c029399b4f257a5dd658d302efe3908)) +- **FIX**: update all Dart SDK version constraints to Dart >= 2.16.0 (#8184). ([df4a5bab](https://github.com/firebase/flutterfire/commit/df4a5bab3c029399b4f257a5dd658d302efe3908)) ## 1.0.0-dev.9 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.8 - - **DOCS**: Update code snippets by removing incorrect forward slash for `@Collection` annotations. (#8044). ([292f20c6](https://github.com/firebase/flutterfire/commit/292f20c61c0a479e5effcbf45a07f7fb782ba23e)) +- **DOCS**: Update code snippets by removing incorrect forward slash for `@Collection` annotations. (#8044). ([292f20c6](https://github.com/firebase/flutterfire/commit/292f20c61c0a479e5effcbf45a07f7fb782ba23e)) ## 1.0.0-dev.7 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.6 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.5 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.4 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.3 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.2 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.1 - * Initial preview release. +- Initial preview release. diff --git a/packages/cloud_firestore_odm/example/integration_test/document_reference_test.dart b/packages/cloud_firestore_odm/example/integration_test/document_reference_test.dart index 1ae925f..465faaf 100644 --- a/packages/cloud_firestore_odm/example/integration_test/document_reference_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/document_reference_test.dart @@ -50,6 +50,50 @@ void main() { ); }); + test('batch', () async { + final collection = await initializeTest(MovieCollectionReference()); + + const movieToUpdate = '123'; + const movieToSet = '456'; + const movieToDelete = '789'; + + await collection.doc(movieToUpdate).set(createMovie(title: 'title1')); + await collection.doc(movieToSet).set(createMovie(title: 'title2')); + await collection.doc(movieToDelete).set(createMovie(title: 'title3')); + + expect( + await Future.wait([ + collection.doc(movieToUpdate).get().then((e) => e.exists), + collection.doc(movieToSet).get().then((e) => e.exists), + collection.doc(movieToDelete).get().then((e) => e.exists), + ]), + [true, true, true], + ); + + const updatedTitle = 'updatedTitle'; + const newTitle = 'newTitle'; + final newMovie = createMovie(title: newTitle); + + final batch = FirebaseFirestore.instance.batch(); + collection.doc(movieToUpdate).batchUpdate(batch, title: updatedTitle); + collection.doc(movieToSet).batchSet(batch, newMovie); + collection.doc(movieToDelete).batchDelete(batch); + await batch.commit(); + + expect( + await Future.wait([ + collection.doc(movieToUpdate).get().then((e) => e.data?.title), + collection.doc(movieToSet).get().then((e) => e.data), + collection.doc(movieToDelete).get().then((e) => e.exists), + ]), + [ + updatedTitle, + isA().having((e) => e.title, newTitle, newTitle), + false, + ], + ); + }); + test('delete', () async { final collection = await initializeTest(MovieCollectionReference()); diff --git a/packages/cloud_firestore_odm/example/lib/integration.g.dart b/packages/cloud_firestore_odm/example/lib/integration.g.dart index 02c8c75..404c246 100644 --- a/packages/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration.g.dart @@ -150,6 +150,17 @@ abstract class AdvancedJsonDocumentReference extends FirestoreDocumentReference< String? lastName, FieldValue lastNameFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String? firstName, + FieldValue firstNameFieldValue, + String? lastName, + FieldValue lastNameFieldValue, + }); } class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< @@ -241,6 +252,37 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? firstName = _sentinel, + FieldValue? firstNameFieldValue, + Object? lastName = _sentinel, + FieldValue? lastNameFieldValue, + }) { + assert( + firstName == _sentinel || firstNameFieldValue == null, + "Cannot specify both firstName and firstNameFieldValue", + ); + assert( + lastName == _sentinel || lastNameFieldValue == null, + "Cannot specify both lastName and lastNameFieldValue", + ); + final json = { + if (firstName != _sentinel) + _$AdvancedJsonFieldMap['firstName']!: + _$AdvancedJsonPerFieldToJson.firstName(firstName as String?), + if (firstNameFieldValue != null) + _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) + _$AdvancedJsonFieldMap['lastName']!: + _$AdvancedJsonPerFieldToJson.lastName(lastName as String?), + if (lastNameFieldValue != null) + _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is AdvancedJsonDocumentReference && @@ -1136,6 +1178,17 @@ abstract class _PrivateAdvancedJsonDocumentReference String? lastName, FieldValue lastNameFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String? firstName, + FieldValue firstNameFieldValue, + String? lastName, + FieldValue lastNameFieldValue, + }); } class _$_PrivateAdvancedJsonDocumentReference @@ -1231,6 +1284,37 @@ class _$_PrivateAdvancedJsonDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? firstName = _sentinel, + FieldValue? firstNameFieldValue, + Object? lastName = _sentinel, + FieldValue? lastNameFieldValue, + }) { + assert( + firstName == _sentinel || firstNameFieldValue == null, + "Cannot specify both firstName and firstNameFieldValue", + ); + assert( + lastName == _sentinel || lastNameFieldValue == null, + "Cannot specify both lastName and lastNameFieldValue", + ); + final json = { + if (firstName != _sentinel) + _$PrivateAdvancedJsonFieldMap['firstName']!: + _$PrivateAdvancedJsonPerFieldToJson.firstName(firstName as String?), + if (firstNameFieldValue != null) + _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) + _$PrivateAdvancedJsonFieldMap['lastName']!: + _$PrivateAdvancedJsonPerFieldToJson.lastName(lastName as String?), + if (lastNameFieldValue != null) + _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is _PrivateAdvancedJsonDocumentReference && diff --git a/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart b/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart index 3d92c41..a77d3e3 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart @@ -159,6 +159,23 @@ abstract class EnumsDocumentReference List? nullableEnumList, FieldValue nullableEnumListFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String id, + FieldValue idFieldValue, + TestEnum enumValue, + FieldValue enumValueFieldValue, + TestEnum? nullableEnumValue, + FieldValue nullableEnumValueFieldValue, + List enumList, + FieldValue enumListFieldValue, + List? nullableEnumList, + FieldValue nullableEnumListFieldValue, + }); } class _$EnumsDocumentReference @@ -312,6 +329,68 @@ class _$EnumsDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? id = _sentinel, + FieldValue? idFieldValue, + Object? enumValue = _sentinel, + FieldValue? enumValueFieldValue, + Object? nullableEnumValue = _sentinel, + FieldValue? nullableEnumValueFieldValue, + Object? enumList = _sentinel, + FieldValue? enumListFieldValue, + Object? nullableEnumList = _sentinel, + FieldValue? nullableEnumListFieldValue, + }) { + assert( + id == _sentinel || idFieldValue == null, + "Cannot specify both id and idFieldValue", + ); + assert( + enumValue == _sentinel || enumValueFieldValue == null, + "Cannot specify both enumValue and enumValueFieldValue", + ); + assert( + nullableEnumValue == _sentinel || nullableEnumValueFieldValue == null, + "Cannot specify both nullableEnumValue and nullableEnumValueFieldValue", + ); + assert( + enumList == _sentinel || enumListFieldValue == null, + "Cannot specify both enumList and enumListFieldValue", + ); + assert( + nullableEnumList == _sentinel || nullableEnumListFieldValue == null, + "Cannot specify both nullableEnumList and nullableEnumListFieldValue", + ); + final json = { + if (id != _sentinel) + _$EnumsFieldMap['id']!: _$EnumsPerFieldToJson.id(id as String), + if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + if (enumValue != _sentinel) + _$EnumsFieldMap['enumValue']!: + _$EnumsPerFieldToJson.enumValue(enumValue as TestEnum), + if (enumValueFieldValue != null) + _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValue != _sentinel) + _$EnumsFieldMap['nullableEnumValue']!: _$EnumsPerFieldToJson + .nullableEnumValue(nullableEnumValue as TestEnum?), + if (nullableEnumValueFieldValue != null) + _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumList != _sentinel) + _$EnumsFieldMap['enumList']!: + _$EnumsPerFieldToJson.enumList(enumList as List), + if (enumListFieldValue != null) + _$EnumsFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumList != _sentinel) + _$EnumsFieldMap['nullableEnumList']!: _$EnumsPerFieldToJson + .nullableEnumList(nullableEnumList as List?), + if (nullableEnumListFieldValue != null) + _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is EnumsDocumentReference && diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart index f17e420..5bb9616 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart @@ -147,6 +147,17 @@ abstract class PersonDocumentReference String lastName, FieldValue lastNameFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String firstName, + FieldValue firstNameFieldValue, + String lastName, + FieldValue lastNameFieldValue, + }); } class _$PersonDocumentReference @@ -238,6 +249,37 @@ class _$PersonDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? firstName = _sentinel, + FieldValue? firstNameFieldValue, + Object? lastName = _sentinel, + FieldValue? lastNameFieldValue, + }) { + assert( + firstName == _sentinel || firstNameFieldValue == null, + "Cannot specify both firstName and firstNameFieldValue", + ); + assert( + lastName == _sentinel || lastNameFieldValue == null, + "Cannot specify both lastName and lastNameFieldValue", + ); + final json = { + if (firstName != _sentinel) + _$$PersonImplFieldMap['firstName']!: + _$$PersonImplPerFieldToJson.firstName(firstName as String), + if (firstNameFieldValue != null) + _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) + _$$PersonImplFieldMap['lastName']!: + _$$PersonImplPerFieldToJson.lastName(lastName as String), + if (lastNameFieldValue != null) + _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is PersonDocumentReference && @@ -1116,6 +1158,15 @@ abstract class PublicRedirectedDocumentReference String value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String value, + FieldValue valueFieldValue, + }); } class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< @@ -1186,6 +1237,26 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$$PublicRedirected2ImplFieldMap['value']!: + _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + if (valueFieldValue != null) + _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is PublicRedirectedDocumentReference && diff --git a/packages/cloud_firestore_odm/example/lib/integration/named_query.g.dart b/packages/cloud_firestore_odm/example/lib/integration/named_query.g.dart index 9848ec2..1f48660 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/named_query.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/named_query.g.dart @@ -162,6 +162,15 @@ abstract class ConflictDocumentReference num number, FieldValue numberFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + num number, + FieldValue numberFieldValue, + }); } class _$ConflictDocumentReference @@ -231,6 +240,26 @@ class _$ConflictDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? number = _sentinel, + FieldValue? numberFieldValue, + }) { + assert( + number == _sentinel || numberFieldValue == null, + "Cannot specify both number and numberFieldValue", + ); + final json = { + if (number != _sentinel) + _$ConflictFieldMap['number']!: + _$ConflictPerFieldToJson.number(number as num), + if (numberFieldValue != null) + _$ConflictFieldMap['number']!: numberFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is ConflictDocumentReference && diff --git a/packages/cloud_firestore_odm/example/lib/integration/query.g.dart b/packages/cloud_firestore_odm/example/lib/integration/query.g.dart index 81c21e8..78ee08b 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/query.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/query.g.dart @@ -148,6 +148,15 @@ abstract class DurationQueryDocumentReference Duration duration, FieldValue durationFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + Duration duration, + FieldValue durationFieldValue, + }); } class _$DurationQueryDocumentReference extends FirestoreDocumentReference< @@ -218,6 +227,26 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? duration = _sentinel, + FieldValue? durationFieldValue, + }) { + assert( + duration == _sentinel || durationFieldValue == null, + "Cannot specify both duration and durationFieldValue", + ); + final json = { + if (duration != _sentinel) + _$DurationQueryFieldMap['duration']!: + _$DurationQueryPerFieldToJson.duration(duration as Duration), + if (durationFieldValue != null) + _$DurationQueryFieldMap['duration']!: durationFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is DurationQueryDocumentReference && @@ -959,6 +988,15 @@ abstract class DateTimeQueryDocumentReference DateTime time, FieldValue timeFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + DateTime time, + FieldValue timeFieldValue, + }); } class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< @@ -1029,6 +1067,26 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? time = _sentinel, + FieldValue? timeFieldValue, + }) { + assert( + time == _sentinel || timeFieldValue == null, + "Cannot specify both time and timeFieldValue", + ); + final json = { + if (time != _sentinel) + _$DateTimeQueryFieldMap['time']!: + _$DateTimeQueryPerFieldToJson.time(time as DateTime), + if (timeFieldValue != null) + _$DateTimeQueryFieldMap['time']!: timeFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is DateTimeQueryDocumentReference && @@ -1772,6 +1830,15 @@ abstract class TimestampQueryDocumentReference Timestamp time, FieldValue timeFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + Timestamp time, + FieldValue timeFieldValue, + }); } class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< @@ -1842,6 +1909,26 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? time = _sentinel, + FieldValue? timeFieldValue, + }) { + assert( + time == _sentinel || timeFieldValue == null, + "Cannot specify both time and timeFieldValue", + ); + final json = { + if (time != _sentinel) + _$TimestampQueryFieldMap['time']!: + _$TimestampQueryPerFieldToJson.time(time as Timestamp), + if (timeFieldValue != null) + _$TimestampQueryFieldMap['time']!: timeFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is TimestampQueryDocumentReference && @@ -2586,6 +2673,15 @@ abstract class GeoPointQueryDocumentReference GeoPoint point, FieldValue pointFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + GeoPoint point, + FieldValue pointFieldValue, + }); } class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< @@ -2656,6 +2752,26 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? point = _sentinel, + FieldValue? pointFieldValue, + }) { + assert( + point == _sentinel || pointFieldValue == null, + "Cannot specify both point and pointFieldValue", + ); + final json = { + if (point != _sentinel) + _$GeoPointQueryFieldMap['point']!: + _$GeoPointQueryPerFieldToJson.point(point as GeoPoint), + if (pointFieldValue != null) + _$GeoPointQueryFieldMap['point']!: pointFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is GeoPointQueryDocumentReference && @@ -3402,6 +3518,15 @@ abstract class DocumentReferenceQueryDocumentReference DocumentReference> ref, FieldValue refFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + DocumentReference> ref, + FieldValue refFieldValue, + }); } class _$DocumentReferenceQueryDocumentReference @@ -3479,6 +3604,27 @@ class _$DocumentReferenceQueryDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? ref = _sentinel, + FieldValue? refFieldValue, + }) { + assert( + ref == _sentinel || refFieldValue == null, + "Cannot specify both ref and refFieldValue", + ); + final json = { + if (ref != _sentinel) + _$DocumentReferenceQueryFieldMap['ref']!: + _$DocumentReferenceQueryPerFieldToJson + .ref(ref as DocumentReference>), + if (refFieldValue != null) + _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is DocumentReferenceQueryDocumentReference && diff --git a/packages/cloud_firestore_odm/example/lib/movie.g.dart b/packages/cloud_firestore_odm/example/lib/movie.g.dart index f8e54d0..185c8ad 100644 --- a/packages/cloud_firestore_odm/example/lib/movie.g.dart +++ b/packages/cloud_firestore_odm/example/lib/movie.g.dart @@ -175,6 +175,29 @@ abstract class MovieDocumentReference Set? tags, FieldValue tagsFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String poster, + FieldValue posterFieldValue, + int likes, + FieldValue likesFieldValue, + String title, + FieldValue titleFieldValue, + int year, + FieldValue yearFieldValue, + String runtime, + FieldValue runtimeFieldValue, + String rated, + FieldValue ratedFieldValue, + List? genre, + FieldValue genreFieldValue, + Set? tags, + FieldValue tagsFieldValue, + }); } class _$MovieDocumentReference @@ -382,6 +405,93 @@ class _$MovieDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? poster = _sentinel, + FieldValue? posterFieldValue, + Object? likes = _sentinel, + FieldValue? likesFieldValue, + Object? title = _sentinel, + FieldValue? titleFieldValue, + Object? year = _sentinel, + FieldValue? yearFieldValue, + Object? runtime = _sentinel, + FieldValue? runtimeFieldValue, + Object? rated = _sentinel, + FieldValue? ratedFieldValue, + Object? genre = _sentinel, + FieldValue? genreFieldValue, + Object? tags = _sentinel, + FieldValue? tagsFieldValue, + }) { + assert( + poster == _sentinel || posterFieldValue == null, + "Cannot specify both poster and posterFieldValue", + ); + assert( + likes == _sentinel || likesFieldValue == null, + "Cannot specify both likes and likesFieldValue", + ); + assert( + title == _sentinel || titleFieldValue == null, + "Cannot specify both title and titleFieldValue", + ); + assert( + year == _sentinel || yearFieldValue == null, + "Cannot specify both year and yearFieldValue", + ); + assert( + runtime == _sentinel || runtimeFieldValue == null, + "Cannot specify both runtime and runtimeFieldValue", + ); + assert( + rated == _sentinel || ratedFieldValue == null, + "Cannot specify both rated and ratedFieldValue", + ); + assert( + genre == _sentinel || genreFieldValue == null, + "Cannot specify both genre and genreFieldValue", + ); + assert( + tags == _sentinel || tagsFieldValue == null, + "Cannot specify both tags and tagsFieldValue", + ); + final json = { + if (poster != _sentinel) + _$MovieFieldMap['poster']!: + _$MoviePerFieldToJson.poster(poster as String), + if (posterFieldValue != null) + _$MovieFieldMap['poster']!: posterFieldValue, + if (likes != _sentinel) + _$MovieFieldMap['likes']!: _$MoviePerFieldToJson.likes(likes as int), + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + if (title != _sentinel) + _$MovieFieldMap['title']!: _$MoviePerFieldToJson.title(title as String), + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + if (year != _sentinel) + _$MovieFieldMap['year']!: _$MoviePerFieldToJson.year(year as int), + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + if (runtime != _sentinel) + _$MovieFieldMap['runtime']!: + _$MoviePerFieldToJson.runtime(runtime as String), + if (runtimeFieldValue != null) + _$MovieFieldMap['runtime']!: runtimeFieldValue, + if (rated != _sentinel) + _$MovieFieldMap['rated']!: _$MoviePerFieldToJson.rated(rated as String), + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + if (genre != _sentinel) + _$MovieFieldMap['genre']!: + _$MoviePerFieldToJson.genre(genre as List?), + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tags != _sentinel) + _$MovieFieldMap['tags']!: + _$MoviePerFieldToJson.tags(tags as Set?), + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is MovieDocumentReference && @@ -2121,6 +2231,17 @@ abstract class CommentDocumentReference String message, FieldValue messageFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String authorName, + FieldValue authorNameFieldValue, + String message, + FieldValue messageFieldValue, + }); } class _$CommentDocumentReference @@ -2217,6 +2338,37 @@ class _$CommentDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? authorName = _sentinel, + FieldValue? authorNameFieldValue, + Object? message = _sentinel, + FieldValue? messageFieldValue, + }) { + assert( + authorName == _sentinel || authorNameFieldValue == null, + "Cannot specify both authorName and authorNameFieldValue", + ); + assert( + message == _sentinel || messageFieldValue == null, + "Cannot specify both message and messageFieldValue", + ); + final json = { + if (authorName != _sentinel) + _$CommentFieldMap['authorName']!: + _$CommentPerFieldToJson.authorName(authorName as String), + if (authorNameFieldValue != null) + _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (message != _sentinel) + _$CommentFieldMap['message']!: + _$CommentPerFieldToJson.message(message as String), + if (messageFieldValue != null) + _$CommentFieldMap['message']!: messageFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is CommentDocumentReference && diff --git a/packages/cloud_firestore_odm/lib/src/firestore_reference.dart b/packages/cloud_firestore_odm/lib/src/firestore_reference.dart index 5adda8a..705f286 100644 --- a/packages/cloud_firestore_odm/lib/src/firestore_reference.dart +++ b/packages/cloud_firestore_odm/lib/src/firestore_reference.dart @@ -76,6 +76,11 @@ abstract class FirestoreDocumentReference=2.18.0 <4.0.0'` `flutter: '>=3.3.0'` ([#10946](https://github.com/firebase/flutterfire/issues/10946)). ([2772d10f](https://github.com/firebase/flutterfire/commit/2772d10fe510dcc28ec2d37a26b266c935699fa6)) +- **FEAT**: update dependency constraints to `sdk: '>=2.18.0 <4.0.0'` `flutter: '>=3.3.0'` ([#10946](https://github.com/firebase/flutterfire/issues/10946)). ([2772d10f](https://github.com/firebase/flutterfire/commit/2772d10fe510dcc28ec2d37a26b266c935699fa6)) ## 1.0.0-dev.57 - - **FEAT**: upgrade to dart 3 compatible dependencies ([#10890](https://github.com/firebase/flutterfire/issues/10890)). ([4bd7e59b](https://github.com/firebase/flutterfire/commit/4bd7e59b1f2b09a2230c49830159342dd4592041)) +- **FEAT**: upgrade to dart 3 compatible dependencies ([#10890](https://github.com/firebase/flutterfire/issues/10890)). ([4bd7e59b](https://github.com/firebase/flutterfire/commit/4bd7e59b1f2b09a2230c49830159342dd4592041)) ## 1.0.0-dev.56 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.55 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.54 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.53 - - **FEAT**: bump dart sdk constraint to 2.18 ([#10618](https://github.com/firebase/flutterfire/issues/10618)). ([f80948a2](https://github.com/firebase/flutterfire/commit/f80948a28b62eead358bdb900d5a0dfb97cebb33)) +- **FEAT**: bump dart sdk constraint to 2.18 ([#10618](https://github.com/firebase/flutterfire/issues/10618)). ([f80948a2](https://github.com/firebase/flutterfire/commit/f80948a28b62eead358bdb900d5a0dfb97cebb33)) ## 1.0.0-dev.52 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.51 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.50 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.49 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.48 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.47 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.46 - - **REFACTOR**: upgrade project to remove warnings from Flutter 3.7 ([#10344](https://github.com/firebase/flutterfire/issues/10344)). ([e0087c84](https://github.com/firebase/flutterfire/commit/e0087c845c7526c11a4241a26d39d4673b0ad29d)) +- **REFACTOR**: upgrade project to remove warnings from Flutter 3.7 ([#10344](https://github.com/firebase/flutterfire/issues/10344)). ([e0087c84](https://github.com/firebase/flutterfire/commit/e0087c845c7526c11a4241a26d39d4673b0ad29d)) ## 1.0.0-dev.45 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.44 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.43 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.42 - - **FIX**: a bug where the ODM does not respect JSON case renaming ([#9988](https://github.com/firebase/flutterfire/issues/9988)). ([02d394b6](https://github.com/firebase/flutterfire/commit/02d394b6b0917f7dc98711b9939630c0b423ed63)) +- **FIX**: a bug where the ODM does not respect JSON case renaming ([#9988](https://github.com/firebase/flutterfire/issues/9988)). ([02d394b6](https://github.com/firebase/flutterfire/commit/02d394b6b0917f7dc98711b9939630c0b423ed63)) ## 1.0.0-dev.41 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.40 - - **FIX**: Improve error handling if a collection and the associated model are defined in separate files. ([#9827](https://github.com/firebase/flutterfire/issues/9827)). ([294e1085](https://github.com/firebase/flutterfire/commit/294e1085ae7af92573657489b78ae0a82ab5e4b4)) +- **FIX**: Improve error handling if a collection and the associated model are defined in separate files. ([#9827](https://github.com/firebase/flutterfire/issues/9827)). ([294e1085](https://github.com/firebase/flutterfire/commit/294e1085ae7af92573657489b78ae0a82ab5e4b4)) ## 1.0.0-dev.39 - - **FIX**: Upgrade analyzer version. ([#9828](https://github.com/firebase/flutterfire/issues/9828)). ([b7f5887d](https://github.com/firebase/flutterfire/commit/b7f5887d76ba11de5041f39d2bb5fdcb8aec288d)) +- **FIX**: Upgrade analyzer version. ([#9828](https://github.com/firebase/flutterfire/issues/9828)). ([b7f5887d](https://github.com/firebase/flutterfire/commit/b7f5887d76ba11de5041f39d2bb5fdcb8aec288d)) ## 1.0.0-dev.38 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.37 - - **FIX**: The ODM correctly no-longer generates query utilities for getters. ([#9766](https://github.com/firebase/flutterfire/issues/9766)). ([cfb56939](https://github.com/firebase/flutterfire/commit/cfb569395cadf6b7bcd8727b680d0b52e4e9297d)) +- **FIX**: The ODM correctly no-longer generates query utilities for getters. ([#9766](https://github.com/firebase/flutterfire/issues/9766)). ([cfb56939](https://github.com/firebase/flutterfire/commit/cfb569395cadf6b7bcd8727b680d0b52e4e9297d)) ## 1.0.0-dev.36 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.35 - - **FEAT**: Add support for FirebaseFirestore.myNamedQueryGet() ([#9721](https://github.com/firebase/flutterfire/issues/9721)). ([82152a00](https://github.com/firebase/flutterfire/commit/82152a0081343a6f7b7d1f5725818825e2b1191a)) +- **FEAT**: Add support for FirebaseFirestore.myNamedQueryGet() ([#9721](https://github.com/firebase/flutterfire/issues/9721)). ([82152a00](https://github.com/firebase/flutterfire/commit/82152a0081343a6f7b7d1f5725818825e2b1191a)) ## 1.0.0-dev.34 - - **FEAT**: Add support for FieldValue ([#9684](https://github.com/firebase/flutterfire/issues/9684)). ([467c403a](https://github.com/firebase/flutterfire/commit/467c403aad5dc9a829450eee22750e172e88f90b)) +- **FEAT**: Add support for FieldValue ([#9684](https://github.com/firebase/flutterfire/issues/9684)). ([467c403a](https://github.com/firebase/flutterfire/commit/467c403aad5dc9a829450eee22750e172e88f90b)) ## 1.0.0-dev.33 - - **FIX**: Update ignored lints in generated files ([#9683](https://github.com/firebase/flutterfire/issues/9683)). ([3ab283bb](https://github.com/firebase/flutterfire/commit/3ab283bb3ec6e5dbc0befefb062c5069959f9fb5)) - - **FEAT**: Add transaction utilities to the ODM ([#9670](https://github.com/firebase/flutterfire/issues/9670)). ([7d84d70a](https://github.com/firebase/flutterfire/commit/7d84d70a1120f7751f5ff817d7b10b330dcf7e06)) +- **FIX**: Update ignored lints in generated files ([#9683](https://github.com/firebase/flutterfire/issues/9683)). ([3ab283bb](https://github.com/firebase/flutterfire/commit/3ab283bb3ec6e5dbc0befefb062c5069959f9fb5)) +- **FEAT**: Add transaction utilities to the ODM ([#9670](https://github.com/firebase/flutterfire/issues/9670)). ([7d84d70a](https://github.com/firebase/flutterfire/commit/7d84d70a1120f7751f5ff817d7b10b330dcf7e06)) ## 1.0.0-dev.32 - - **FEAT**: Allow injecting the document ID in the ODM model ([#9600](https://github.com/firebase/flutterfire/issues/9600)). ([c7e93cfe](https://github.com/firebase/flutterfire/commit/c7e93cfec14e0e00bcabb232760ae5a968a1c2a1)) +- **FEAT**: Allow injecting the document ID in the ODM model ([#9600](https://github.com/firebase/flutterfire/issues/9600)). ([c7e93cfe](https://github.com/firebase/flutterfire/commit/c7e93cfec14e0e00bcabb232760ae5a968a1c2a1)) ## 1.0.0-dev.31 - - **FIX**: a false positive by checking that there are no prefix duplicates. ([#9576](https://github.com/firebase/flutterfire/issues/9576)). ([d6f619c9](https://github.com/firebase/flutterfire/commit/d6f619c90fadb5057a8db1d69921cd4e2f5c1816)) - - **FIX**: handle query.orderBy(startAt:).orderBy() ([#9185](https://github.com/firebase/flutterfire/issues/9185)). ([62396e8a](https://github.com/firebase/flutterfire/commit/62396e8a4a229dfc096d6280964bb559c00b3511)) +- **FIX**: a false positive by checking that there are no prefix duplicates. ([#9576](https://github.com/firebase/flutterfire/issues/9576)). ([d6f619c9](https://github.com/firebase/flutterfire/commit/d6f619c90fadb5057a8db1d69921cd4e2f5c1816)) +- **FIX**: handle query.orderBy(startAt:).orderBy() ([#9185](https://github.com/firebase/flutterfire/issues/9185)). ([62396e8a](https://github.com/firebase/flutterfire/commit/62396e8a4a229dfc096d6280964bb559c00b3511)) ## 1.0.0-dev.30 - - **FEAT**: add support for specifying class name prefix ([#9453](https://github.com/firebase/flutterfire/issues/9453)). ([49921a43](https://github.com/firebase/flutterfire/commit/49921a4362c5965d2efeed17eb73775302007ea8)) +- **FEAT**: add support for specifying class name prefix ([#9453](https://github.com/firebase/flutterfire/issues/9453)). ([49921a43](https://github.com/firebase/flutterfire/commit/49921a4362c5965d2efeed17eb73775302007ea8)) ## 1.0.0-dev.29 - - **FIX**: bump minimum analyzer version ([#9493](https://github.com/firebase/flutterfire/issues/9493)). ([5137a646](https://github.com/firebase/flutterfire/commit/5137a6469fb57fb003757459222cb6c4e39fb0f8)) - - **FEAT**: Add support using Freezed classes as collection models ([#9483](https://github.com/firebase/flutterfire/issues/9483)). ([ce238f71](https://github.com/firebase/flutterfire/commit/ce238f713b250f523890b9e7e42d395f433ed80f)) +- **FIX**: bump minimum analyzer version ([#9493](https://github.com/firebase/flutterfire/issues/9493)). ([5137a646](https://github.com/firebase/flutterfire/commit/5137a6469fb57fb003757459222cb6c4e39fb0f8)) +- **FEAT**: Add support using Freezed classes as collection models ([#9483](https://github.com/firebase/flutterfire/issues/9483)). ([ce238f71](https://github.com/firebase/flutterfire/commit/ce238f713b250f523890b9e7e42d395f433ed80f)) ## 1.0.0-dev.28 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.27 - - **FIX**: replace deprecated elements from analyzer ([#9366](https://github.com/firebase/flutterfire/issues/9366)). ([89c4c429](https://github.com/firebase/flutterfire/commit/89c4c4294dc6fb376caf74704abf738ec664f85f)) +- **FIX**: replace deprecated elements from analyzer ([#9366](https://github.com/firebase/flutterfire/issues/9366)). ([89c4c429](https://github.com/firebase/flutterfire/commit/89c4c4294dc6fb376caf74704abf738ec664f85f)) ## 1.0.0-dev.26 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.25 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.24 > Note: This release has breaking changes. - - **FEAT**: Add where(arrayContains) support ([#9167](https://github.com/firebase/flutterfire/issues/9167)). ([1a2f2262](https://github.com/firebase/flutterfire/commit/1a2f2262578c6230560761630d017637b99cbd6c)) - - **BREAKING** **FEAT**: The low-level interface of Queries/Document ([#9184](https://github.com/firebase/flutterfire/issues/9184)). ([fad4b0cd](https://github.com/firebase/flutterfire/commit/fad4b0cd0aa09e9161c64deeecf222c14603cd69)) +- **FEAT**: Add where(arrayContains) support ([#9167](https://github.com/firebase/flutterfire/issues/9167)). ([1a2f2262](https://github.com/firebase/flutterfire/commit/1a2f2262578c6230560761630d017637b99cbd6c)) +- **BREAKING** **FEAT**: The low-level interface of Queries/Document ([#9184](https://github.com/firebase/flutterfire/issues/9184)). ([fad4b0cd](https://github.com/firebase/flutterfire/commit/fad4b0cd0aa09e9161c64deeecf222c14603cd69)) ## 1.0.0-dev.23 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.22 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.21 - - **FEAT**: add orderByFieldPath / whereFieldPath ([#8951](https://github.com/firebase/flutterfire/issues/8951)). ([5957c23b](https://github.com/firebase/flutterfire/commit/5957c23b44b235dab9d97449acb9c737da07b8e7)) - - **FEAT**: Add support for DateTime/Timestamp/GeoPoint ([#8563](https://github.com/firebase/flutterfire/issues/8563)). ([f2ea3696](https://github.com/firebase/flutterfire/commit/f2ea36964662d396dbc26bd931bb2662a5898168)) - - **FEAT**: add support for json_serializable's field rename/property ignore ([#9030](https://github.com/firebase/flutterfire/issues/9030)). ([81ec08fd](https://github.com/firebase/flutterfire/commit/81ec08fd64d57b4fbdc8e4fca39b5ab84dcc8669)) +- **FEAT**: add orderByFieldPath / whereFieldPath ([#8951](https://github.com/firebase/flutterfire/issues/8951)). ([5957c23b](https://github.com/firebase/flutterfire/commit/5957c23b44b235dab9d97449acb9c737da07b8e7)) +- **FEAT**: Add support for DateTime/Timestamp/GeoPoint ([#8563](https://github.com/firebase/flutterfire/issues/8563)). ([f2ea3696](https://github.com/firebase/flutterfire/commit/f2ea36964662d396dbc26bd931bb2662a5898168)) +- **FEAT**: add support for json_serializable's field rename/property ignore ([#9030](https://github.com/firebase/flutterfire/issues/9030)). ([81ec08fd](https://github.com/firebase/flutterfire/commit/81ec08fd64d57b4fbdc8e4fca39b5ab84dcc8669)) ## 1.0.0-dev.20 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.19 - - **FEAT**: add whereDocumentId/orderByDocumentId (#8935). ([3769bcca](https://github.com/firebase/flutterfire/commit/3769bccadedc2c12228ec51dfb48561a23055370)) +- **FEAT**: add whereDocumentId/orderByDocumentId (#8935). ([3769bcca](https://github.com/firebase/flutterfire/commit/3769bccadedc2c12228ec51dfb48561a23055370)) ## 1.0.0-dev.18 - - **REFACTOR**: use "firebase" instead of "FirebaseExtended" as organisation in all links for this repository (#8791). ([d90b8357](https://github.com/firebase/flutterfire/commit/d90b8357db01d65e753021358668f0b129713e6b)) +- **REFACTOR**: use "firebase" instead of "FirebaseExtended" as organisation in all links for this repository (#8791). ([d90b8357](https://github.com/firebase/flutterfire/commit/d90b8357db01d65e753021358668f0b129713e6b)) ## 1.0.0-dev.17 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.16 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.15 - - **FIX**: ODM should no-longer generates update/query functions for nested objects ([#8661](https://github.com/firebase/flutterfire/issues/8661)). ([84eeed2e](https://github.com/firebase/flutterfire/commit/84eeed2ec8da3aac87befd2028f8052005319730)) - - **FEAT**: Assert that collection.doc(id) does not point to a separate collection ([#8676](https://github.com/firebase/flutterfire/issues/8676)). ([0808205b](https://github.com/firebase/flutterfire/commit/0808205bdca03fc913015f00f5ffc2e1d018adb9)) +- **FIX**: ODM should no-longer generates update/query functions for nested objects ([#8661](https://github.com/firebase/flutterfire/issues/8661)). ([84eeed2e](https://github.com/firebase/flutterfire/commit/84eeed2ec8da3aac87befd2028f8052005319730)) +- **FEAT**: Assert that collection.doc(id) does not point to a separate collection ([#8676](https://github.com/firebase/flutterfire/issues/8676)). ([0808205b](https://github.com/firebase/flutterfire/commit/0808205bdca03fc913015f00f5ffc2e1d018adb9)) ## 1.0.0-dev.14 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.13 - - **FEAT**: upgrade analyzer, freezed_annotation and json_serializable dependencies (#8465). ([8a27ab21](https://github.com/firebase/flutterfire/commit/8a27ab21279d72998e80aa17b8ec39a9e4a08ec8)) +- **FEAT**: upgrade analyzer, freezed_annotation and json_serializable dependencies (#8465). ([8a27ab21](https://github.com/firebase/flutterfire/commit/8a27ab21279d72998e80aa17b8ec39a9e4a08ec8)) ## 1.0.0-dev.12 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.11 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.10 - - **FIX**: update all Dart SDK version constraints to Dart >= 2.16.0 (#8184). ([df4a5bab](https://github.com/firebase/flutterfire/commit/df4a5bab3c029399b4f257a5dd658d302efe3908)) +- **FIX**: update all Dart SDK version constraints to Dart >= 2.16.0 (#8184). ([df4a5bab](https://github.com/firebase/flutterfire/commit/df4a5bab3c029399b4f257a5dd658d302efe3908)) ## 1.0.0-dev.9 - - **FIX**: Use descending in orderBy* (#8159). ([0b7b8811](https://github.com/firebase/flutterfire/commit/0b7b88117ac65a0ab164ffcaa0ca7fa69633fcb2)) +- **FIX**: Use descending in orderBy\* (#8159). ([0b7b8811](https://github.com/firebase/flutterfire/commit/0b7b88117ac65a0ab164ffcaa0ca7fa69633fcb2)) ## 1.0.0-dev.8 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.7 - - **FEAT**: Added error handling for when the Firestore reference and the Model class are defined in two separate files. (#7885). ([43cb91c9](https://github.com/firebase/flutterfire/commit/43cb91c9f22c7b61d7170305b9007c5beccfbdae)) +- **FEAT**: Added error handling for when the Firestore reference and the Model class are defined in two separate files. (#7885). ([43cb91c9](https://github.com/firebase/flutterfire/commit/43cb91c9f22c7b61d7170305b9007c5beccfbdae)) ## 1.0.0-dev.6 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.5 - - **FIX**: an issue where invalid code was generated when a model has no queryable fields (#7604). +- **FIX**: an issue where invalid code was generated when a model has no queryable fields (#7604). ## 1.0.0-dev.4 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.3 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.2 - - Update a dependency to the latest release. +- Update a dependency to the latest release. ## 1.0.0-dev.1 - * Initial preview release. +- Initial preview release. diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart index 5878017..e8bffe7 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart @@ -145,6 +145,17 @@ abstract class PersonDocumentReference String lastName, FieldValue lastNameFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String firstName, + FieldValue firstNameFieldValue, + String lastName, + FieldValue lastNameFieldValue, + }); } class _$PersonDocumentReference @@ -236,6 +247,37 @@ class _$PersonDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? firstName = _sentinel, + FieldValue? firstNameFieldValue, + Object? lastName = _sentinel, + FieldValue? lastNameFieldValue, + }) { + assert( + firstName == _sentinel || firstNameFieldValue == null, + "Cannot specify both firstName and firstNameFieldValue", + ); + assert( + lastName == _sentinel || lastNameFieldValue == null, + "Cannot specify both lastName and lastNameFieldValue", + ); + final json = { + if (firstName != _sentinel) + _$$PersonImplFieldMap['firstName']!: + _$$PersonImplPerFieldToJson.firstName(firstName as String), + if (firstNameFieldValue != null) + _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) + _$$PersonImplFieldMap['lastName']!: + _$$PersonImplPerFieldToJson.lastName(lastName as String), + if (lastNameFieldValue != null) + _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is PersonDocumentReference && @@ -1114,6 +1156,15 @@ abstract class PublicRedirectedDocumentReference String value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String value, + FieldValue valueFieldValue, + }); } class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< @@ -1184,6 +1235,26 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$$PublicRedirected2ImplFieldMap['value']!: + _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + if (valueFieldValue != null) + _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is PublicRedirectedDocumentReference && diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart index bd76991..72a40a1 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart @@ -146,6 +146,15 @@ abstract class IgnoredGetterDocumentReference int value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + int value, + FieldValue valueFieldValue, + }); } class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< @@ -216,6 +225,26 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$IgnoredGetterFieldMap['value']!: + _$IgnoredGetterPerFieldToJson.value(value as int), + if (valueFieldValue != null) + _$IgnoredGetterFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is IgnoredGetterDocumentReference && @@ -950,6 +979,15 @@ abstract class ModelDocumentReference String value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String value, + FieldValue valueFieldValue, + }); } class _$ModelDocumentReference @@ -1015,6 +1053,24 @@ class _$ModelDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$ModelFieldMap['value']!: _$ModelPerFieldToJson.value(value as String), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is ModelDocumentReference && @@ -1787,6 +1843,39 @@ abstract class NestedDocumentReference List? nullableEnumList, FieldValue nullableEnumListFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + Nested? value, + FieldValue valueFieldValue, + int? simple, + FieldValue simpleFieldValue, + List? valueList, + FieldValue valueListFieldValue, + List? boolList, + FieldValue boolListFieldValue, + List? stringList, + FieldValue stringListFieldValue, + List? numList, + FieldValue numListFieldValue, + List? objectList, + FieldValue objectListFieldValue, + List? dynamicList, + FieldValue dynamicListFieldValue, + Set? boolSet, + FieldValue boolSetFieldValue, + TestEnum enumValue, + FieldValue enumValueFieldValue, + TestEnum? nullableEnumValue, + FieldValue nullableEnumValueFieldValue, + List enumList, + FieldValue enumListFieldValue, + List? nullableEnumList, + FieldValue nullableEnumListFieldValue, + }); } class _$NestedDocumentReference @@ -2118,6 +2207,157 @@ class _$NestedDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + Object? simple = _sentinel, + FieldValue? simpleFieldValue, + Object? valueList = _sentinel, + FieldValue? valueListFieldValue, + Object? boolList = _sentinel, + FieldValue? boolListFieldValue, + Object? stringList = _sentinel, + FieldValue? stringListFieldValue, + Object? numList = _sentinel, + FieldValue? numListFieldValue, + Object? objectList = _sentinel, + FieldValue? objectListFieldValue, + Object? dynamicList = _sentinel, + FieldValue? dynamicListFieldValue, + Object? boolSet = _sentinel, + FieldValue? boolSetFieldValue, + Object? enumValue = _sentinel, + FieldValue? enumValueFieldValue, + Object? nullableEnumValue = _sentinel, + FieldValue? nullableEnumValueFieldValue, + Object? enumList = _sentinel, + FieldValue? enumListFieldValue, + Object? nullableEnumList = _sentinel, + FieldValue? nullableEnumListFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + assert( + simple == _sentinel || simpleFieldValue == null, + "Cannot specify both simple and simpleFieldValue", + ); + assert( + valueList == _sentinel || valueListFieldValue == null, + "Cannot specify both valueList and valueListFieldValue", + ); + assert( + boolList == _sentinel || boolListFieldValue == null, + "Cannot specify both boolList and boolListFieldValue", + ); + assert( + stringList == _sentinel || stringListFieldValue == null, + "Cannot specify both stringList and stringListFieldValue", + ); + assert( + numList == _sentinel || numListFieldValue == null, + "Cannot specify both numList and numListFieldValue", + ); + assert( + objectList == _sentinel || objectListFieldValue == null, + "Cannot specify both objectList and objectListFieldValue", + ); + assert( + dynamicList == _sentinel || dynamicListFieldValue == null, + "Cannot specify both dynamicList and dynamicListFieldValue", + ); + assert( + boolSet == _sentinel || boolSetFieldValue == null, + "Cannot specify both boolSet and boolSetFieldValue", + ); + assert( + enumValue == _sentinel || enumValueFieldValue == null, + "Cannot specify both enumValue and enumValueFieldValue", + ); + assert( + nullableEnumValue == _sentinel || nullableEnumValueFieldValue == null, + "Cannot specify both nullableEnumValue and nullableEnumValueFieldValue", + ); + assert( + enumList == _sentinel || enumListFieldValue == null, + "Cannot specify both enumList and enumListFieldValue", + ); + assert( + nullableEnumList == _sentinel || nullableEnumListFieldValue == null, + "Cannot specify both nullableEnumList and nullableEnumListFieldValue", + ); + final json = { + if (value != _sentinel) + _$NestedFieldMap['value']!: + _$NestedPerFieldToJson.value(value as Nested?), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simple != _sentinel) + _$NestedFieldMap['simple']!: + _$NestedPerFieldToJson.simple(simple as int?), + if (simpleFieldValue != null) + _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueList != _sentinel) + _$NestedFieldMap['valueList']!: + _$NestedPerFieldToJson.valueList(valueList as List?), + if (valueListFieldValue != null) + _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolList != _sentinel) + _$NestedFieldMap['boolList']!: + _$NestedPerFieldToJson.boolList(boolList as List?), + if (boolListFieldValue != null) + _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringList != _sentinel) + _$NestedFieldMap['stringList']!: + _$NestedPerFieldToJson.stringList(stringList as List?), + if (stringListFieldValue != null) + _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numList != _sentinel) + _$NestedFieldMap['numList']!: + _$NestedPerFieldToJson.numList(numList as List?), + if (numListFieldValue != null) + _$NestedFieldMap['numList']!: numListFieldValue, + if (objectList != _sentinel) + _$NestedFieldMap['objectList']!: + _$NestedPerFieldToJson.objectList(objectList as List?), + if (objectListFieldValue != null) + _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicList != _sentinel) + _$NestedFieldMap['dynamicList']!: + _$NestedPerFieldToJson.dynamicList(dynamicList as List?), + if (dynamicListFieldValue != null) + _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSet != _sentinel) + _$NestedFieldMap['boolSet']!: + _$NestedPerFieldToJson.boolSet(boolSet as Set?), + if (boolSetFieldValue != null) + _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValue != _sentinel) + _$NestedFieldMap['enumValue']!: + _$NestedPerFieldToJson.enumValue(enumValue as TestEnum), + if (enumValueFieldValue != null) + _$NestedFieldMap['enumValue']!: enumValueFieldValue, + if (nullableEnumValue != _sentinel) + _$NestedFieldMap['nullableEnumValue']!: _$NestedPerFieldToJson + .nullableEnumValue(nullableEnumValue as TestEnum?), + if (nullableEnumValueFieldValue != null) + _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + if (enumList != _sentinel) + _$NestedFieldMap['enumList']!: + _$NestedPerFieldToJson.enumList(enumList as List), + if (enumListFieldValue != null) + _$NestedFieldMap['enumList']!: enumListFieldValue, + if (nullableEnumList != _sentinel) + _$NestedFieldMap['nullableEnumList']!: _$NestedPerFieldToJson + .nullableEnumList(nullableEnumList as List?), + if (nullableEnumListFieldValue != null) + _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is NestedDocumentReference && @@ -5230,6 +5470,15 @@ abstract class OptionalJsonDocumentReference extends FirestoreDocumentReference< int value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + int value, + FieldValue valueFieldValue, + }); } class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< @@ -5299,6 +5548,26 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$OptionalJsonFieldMap['value']!: + _$OptionalJsonPerFieldToJson.value(value as int), + if (valueFieldValue != null) + _$OptionalJsonFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is OptionalJsonDocumentReference && @@ -6033,6 +6302,15 @@ abstract class MixedJsonDocumentReference int value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + int value, + FieldValue valueFieldValue, + }); } class _$MixedJsonDocumentReference @@ -6102,6 +6380,26 @@ class _$MixedJsonDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$MixedJsonFieldMap['value']!: + _$MixedJsonPerFieldToJson.value(value as int), + if (valueFieldValue != null) + _$MixedJsonFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is MixedJsonDocumentReference && @@ -6853,6 +7151,17 @@ abstract class RootDocumentReference int? nullable, FieldValue nullableFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String nonNullable, + FieldValue nonNullableFieldValue, + int? nullable, + FieldValue nullableFieldValue, + }); } class _$RootDocumentReference @@ -6963,6 +7272,37 @@ class _$RootDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? nonNullable = _sentinel, + FieldValue? nonNullableFieldValue, + Object? nullable = _sentinel, + FieldValue? nullableFieldValue, + }) { + assert( + nonNullable == _sentinel || nonNullableFieldValue == null, + "Cannot specify both nonNullable and nonNullableFieldValue", + ); + assert( + nullable == _sentinel || nullableFieldValue == null, + "Cannot specify both nullable and nullableFieldValue", + ); + final json = { + if (nonNullable != _sentinel) + _$RootFieldMap['nonNullable']!: + _$RootPerFieldToJson.nonNullable(nonNullable as String), + if (nonNullableFieldValue != null) + _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) + _$RootFieldMap['nullable']!: + _$RootPerFieldToJson.nullable(nullable as int?), + if (nullableFieldValue != null) + _$RootFieldMap['nullable']!: nullableFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is RootDocumentReference && @@ -7842,6 +8182,17 @@ abstract class SubDocumentReference int? nullable, FieldValue nullableFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + String nonNullable, + FieldValue nonNullableFieldValue, + int? nullable, + FieldValue nullableFieldValue, + }); } class _$SubDocumentReference @@ -7938,6 +8289,37 @@ class _$SubDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? nonNullable = _sentinel, + FieldValue? nonNullableFieldValue, + Object? nullable = _sentinel, + FieldValue? nullableFieldValue, + }) { + assert( + nonNullable == _sentinel || nonNullableFieldValue == null, + "Cannot specify both nonNullable and nonNullableFieldValue", + ); + assert( + nullable == _sentinel || nullableFieldValue == null, + "Cannot specify both nullable and nullableFieldValue", + ); + final json = { + if (nonNullable != _sentinel) + _$SubFieldMap['nonNullable']!: + _$SubPerFieldToJson.nonNullable(nonNullable as String), + if (nonNullableFieldValue != null) + _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) + _$SubFieldMap['nullable']!: + _$SubPerFieldToJson.nullable(nullable as int?), + if (nullableFieldValue != null) + _$SubFieldMap['nullable']!: nullableFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is SubDocumentReference && @@ -8818,6 +9200,15 @@ abstract class AsCamelCaseDocumentReference extends FirestoreDocumentReference< num value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + num value, + FieldValue valueFieldValue, + }); } class _$AsCamelCaseDocumentReference @@ -8892,6 +9283,26 @@ class _$AsCamelCaseDocumentReference transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$AsCamelCaseFieldMap['value']!: + _$AsCamelCasePerFieldToJson.value(value as num), + if (valueFieldValue != null) + _$AsCamelCaseFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is AsCamelCaseDocumentReference && @@ -9643,6 +10054,15 @@ abstract class CustomSubNameDocumentReference num value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + num value, + FieldValue valueFieldValue, + }); } class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< @@ -9718,6 +10138,26 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$CustomSubNameFieldMap['value']!: + _$CustomSubNamePerFieldToJson.value(value as num), + if (valueFieldValue != null) + _$CustomSubNameFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is CustomSubNameDocumentReference && @@ -10471,6 +10911,15 @@ abstract class ThisIsACustomPrefixDocumentReference num value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + num value, + FieldValue valueFieldValue, + }); } class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< @@ -10548,6 +10997,26 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$CustomClassPrefixFieldMap['value']!: + _$CustomClassPrefixPerFieldToJson.value(value as num), + if (valueFieldValue != null) + _$CustomClassPrefixFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is ThisIsACustomPrefixDocumentReference && @@ -11298,6 +11767,15 @@ abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< num value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + num value, + FieldValue valueFieldValue, + }); } class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< @@ -11372,6 +11850,26 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$ExplicitPathFieldMap['value']!: + _$ExplicitPathPerFieldToJson.value(value as num), + if (valueFieldValue != null) + _$ExplicitPathFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is ExplicitPathDocumentReference && @@ -12124,6 +12622,15 @@ abstract class ExplicitSubPathDocumentReference num value, FieldValue valueFieldValue, }); + + /// Updates fields in the current document using the batch API. + /// + /// The update will fail if applied to a document that does not exist. + void batchUpdate( + WriteBatch batch, { + num value, + FieldValue valueFieldValue, + }); } class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< @@ -12199,6 +12706,26 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< transaction.update(reference, json); } + void batchUpdate( + WriteBatch batch, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$ExplicitSubPathFieldMap['value']!: + _$ExplicitSubPathPerFieldToJson.value(value as num), + if (valueFieldValue != null) + _$ExplicitSubPathFieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + @override bool operator ==(Object other) { return other is ExplicitSubPathDocumentReference && diff --git a/packages/cloud_firestore_odm_generator/lib/src/templates/document_reference.dart b/packages/cloud_firestore_odm_generator/lib/src/templates/document_reference.dart index 27ecbdb..de6b643 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/templates/document_reference.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/templates/document_reference.dart @@ -89,6 +89,11 @@ Future update({${parameters.join()}}); /// /// The update will fail if applied to a document that does not exist. void transactionUpdate(Transaction transaction, {${parameters.join()}}); + +/// Updates fields in the current document using the batch API. +/// +/// The update will fail if applied to a document that does not exist. +void batchUpdate(WriteBatch batch, {${parameters.join()}}); '''; } @@ -139,6 +144,13 @@ void transactionUpdate(Transaction transaction, {${parameters.join()}}) { transaction.update(reference, json); } + +void batchUpdate(WriteBatch batch, {${parameters.join()}}) { + $asserts + final json = {${json.join()}}; + + batch.update(reference, json); +} '''; } diff --git a/packages/cloud_firestore_odm_generator/pubspec.yaml b/packages/cloud_firestore_odm_generator/pubspec.yaml index 99f15ec..d94b2b7 100644 --- a/packages/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/pubspec.yaml @@ -2,7 +2,7 @@ name: cloud_firestore_odm_generator description: A code generator for cloud_firestore_odm. homepage: https://firebase.flutter.dev/docs/firestore/odm repository: https://github.com/firebaseextended/firestoreodm-flutter -version: 1.0.0-dev.86 +version: 1.0.0-dev.87 environment: sdk: ">=2.18.0 <4.0.0"