diff --git a/README.md b/README.md index 5633a8b..bbc6818 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,12 @@ The ODM allows data schemas to be defined which represent the data structure of - 🎯 Data selectors to help avoid unnecessary Widget rebuilds. - 💻 Full API code completion. +## Compatibility + +- **Freezed**: Compatible with Freezed 3.0.0 and above +- **Analyzer**: Supports analyzer 7.0.0 and above +- **Source Gen**: Compatible with source_gen 2.0.0 and above + ## Installation ### 1. Use a recent Dart version @@ -34,7 +40,7 @@ That is done by adding the following to your `pubspec.yaml`: ```yaml environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" ``` ### 2. FlutterFire Initialization @@ -104,6 +110,24 @@ class MyModel {...} Once installed, read the documentation on [defining models](./docs/defining-models.md). + +## Development +### Testing +To run tests, you should have chromedriver install on your system. +```shell +./scripts/run-tests.sh +``` +Note: make sure in `packages/cloud_firestore_odm_generator/pubspec.yaml` to replace +``` +cloud_firestore_odm: {VERSION} +``` +with +``` +cloud_firestore_odm: + path: ../cloud_firestore_odm +``` +This is required for the tests to run. Set back to correct version before deploying. + ## Issues and feedback Please file FlutterFire specific issues, bugs, or feature requests in our [issue tracker](https://github.com/firebaseextended/firestoreodm-flutter/issues/new). diff --git a/docs/code-generation.md b/docs/code-generation.md index 8d76a72..277bf2b 100644 --- a/docs/code-generation.md +++ b/docs/code-generation.md @@ -22,12 +22,13 @@ generated code: dart run build_runner watch --delete-conflicting-outputs ``` -This will generate files with the postfix of `.g.dart`, corresponding to the +This will generate files with the postfix of `.firebase.dart`, corresponding to the file name of your model. For example: - A model is defined within a file named `product.dart`. -- Code generation will create a file in the same directory named `product.g.dart`. -- Within the `product.dart` file, apply the part declaration (`part 'product.g.dart'`). +- Code generation will create a file in the same directory named `product.firebase.dart`. +- Within the `product.dart` file, apply the part declaration (`part 'product.firebase.dart'`). +- You should also have a `.g.dart` for the json serilizer (`part 'product.g.dart'`). ## Next steps diff --git a/docs/defining-models.md b/docs/defining-models.md index b247a3d..afbddd8 100644 --- a/docs/defining-models.md +++ b/docs/defining-models.md @@ -27,6 +27,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; // This doesn't exist yet...! See "Next Steps" +part 'user.firebase.dart'; part 'user.g.dart'; /// A custom JsonSerializable annotation that supports decoding objects such diff --git a/packages/cloud_firestore_odm/CHANGELOG.md b/packages/cloud_firestore_odm/CHANGELOG.md index aec44da..c1ea7a0 100644 --- a/packages/cloud_firestore_odm/CHANGELOG.md +++ b/packages/cloud_firestore_odm/CHANGELOG.md @@ -1,3 +1,18 @@ +## 2.0.0 +- **BREAKING**: Must include a "part '.firebase.dart';" instead of just part "'.g.dart';". This is because of compatibilty with Riverpod ^3. + +## 1.3.0 +- **CHORE**: upgraded packages to support analyzer ^8 and min sdk to 3.8.0 + +## 1.2.0 +- **CHORE**: Update cloud_firestore to ^6.0.0 + +## 1.1.0 + +- **FIX**: Resolve compatibility issues with Freezed 3.0.0 and above +- **FEAT**: Support analyzer 7.0.0 and above +- **CHORE**: Update dependencies to latest versions + ## 1.0.0-dev.88 - **BREAKING**: Removes `set` methods from `FirestoreDocumentReference` to make way for generated methods diff --git a/packages/cloud_firestore_odm/README.md b/packages/cloud_firestore_odm/README.md index f3bf4c2..3ccd508 100755 --- a/packages/cloud_firestore_odm/README.md +++ b/packages/cloud_firestore_odm/README.md @@ -7,6 +7,12 @@ To learn more about Firebase Cloud Firestore, please visit the [Firebase website [![pub package](https://img.shields.io/pub/v/cloud_firestore_odm.svg)](https://pub.dev/packages/cloud_firestore_odm) +## Compatibility + +- **Freezed**: Compatible with Freezed 3.0.0 and above +- **Analyzer**: Supports analyzer 7.0.0 and above +- **Source Gen**: Compatible with source_gen 2.0.0 and above + ## Getting Started To get started with Cloud Firestore for Flutter, please [see the documentation](https://github.com/firebaseextended/firestoreodm-flutter/tree/main/docs). diff --git a/packages/cloud_firestore_odm/example/integration_test/cloud_firestore_odm_e2e_test.dart b/packages/cloud_firestore_odm/example/integration_test/cloud_firestore_odm_e2e_test.dart index 6b1642c..3875a50 100644 --- a/packages/cloud_firestore_odm/example/integration_test/cloud_firestore_odm_e2e_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/cloud_firestore_odm_e2e_test.dart @@ -9,9 +9,8 @@ import 'package:integration_test/integration_test.dart'; import 'collection_reference_test.dart' as collection_reference_test; import 'document_reference_test.dart' as document_reference_test; - import 'firebase_options.dart'; - +import 'freezed_test.dart' as freezed_test; import 'path_test.dart' as path_test; import 'query_reference_test.dart' as query_reference_test; @@ -32,5 +31,6 @@ void main() { // firestore_builder_test.main(); query_reference_test.main(); path_test.main(); + freezed_test.main(); }); } diff --git a/packages/cloud_firestore_odm/example/integration_test/collection_reference_test.dart b/packages/cloud_firestore_odm/example/integration_test/collection_reference_test.dart index 2d9ec22..82b77a0 100644 --- a/packages/cloud_firestore_odm/example/integration_test/collection_reference_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/collection_reference_test.dart @@ -49,16 +49,12 @@ void main() { expect(b.data?.id, '456'); }); - test( - 'When using @Id, set/update do not insert an "id" property in the document', - () async { + test('When using @Id, set/update do not insert an "id" property in the document', () async { final collection = await initializeTest(MovieCollectionReference()); await collection.doc('123').set(createMovie(title: 'a', id: '42')); - final snapshot = await FirebaseFirestore.instance - .doc(collection.doc('123').path) - .get(); + final snapshot = await FirebaseFirestore.instance.doc(collection.doc('123').path).get(); expect(snapshot.data()?.containsKey('id'), false); }); @@ -67,8 +63,7 @@ void main() { test('reference', () async { expect( MovieCollectionReference().reference, - isA>() - .having((e) => e.path, 'path', 'firestore-example-app'), + isA>().having((e) => e.path, 'path', 'firestore-example-app'), ); expect( @@ -137,14 +132,12 @@ void main() { expect( await stream.next, isA().having((e) => e.docs, 'doc', [ - isA() - .having((e) => e.data.title, 'data.title', 'title'), + isA().having((e) => e.data.title, 'data.title', 'title'), ]), ); }); - test('emits an error if decoding fails, but keeps listening to updates', - () async { + test('emits an error if decoding fails, but keeps listening to updates', () async { final collection = await initializeTest(MovieCollectionReference()); await FirebaseFirestore.instance @@ -185,8 +178,7 @@ void main() { }); group('doc', () { - test('generates a custom ID for documents if none is specified', - () async { + test('generates a custom ID for documents if none is specified', () async { final collection = await initializeTest(MovieCollectionReference()); final doc = collection.doc(); @@ -200,10 +192,7 @@ void main() { test('can specify a custom ID to obtain an existing doc', () async { final collection = await initializeTest(MovieCollectionReference()); - await FirebaseFirestore.instance - .collection('firestore-example-app') - .doc('123') - .set( + await FirebaseFirestore.instance.collection('firestore-example-app').doc('123').set( MovieCollectionReference.toFirestore( createMovie(title: 'title'), null, @@ -217,8 +206,7 @@ void main() { expect( await doc.get(), - isA() - .having((e) => e.data?.title, 'data.title', 'title'), + isA().having((e) => e.data?.title, 'data.title', 'title'), ); }); }); @@ -256,16 +244,14 @@ void main() { stream, emits( isA().having((e) => e.docs, 'doc', [ - isA() - .having((e) => e.data.title, 'data.title', 'Foo'), + isA().having((e) => e.data.title, 'data.title', 'Foo'), ]), ), ); expect( await newDoc.get(), - isA() - .having((e) => e.data?.title, 'data.title', 'Foo'), + isA().having((e) => e.data?.title, 'data.title', 'Foo'), ); }); @@ -282,10 +268,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), - isA() - .having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'B'), ], ); }); @@ -299,16 +283,13 @@ void main() { final bSnap = await b.get(); - final querySnap = - await collection.orderByTitle(endAtDocument: bSnap).get(); + final querySnap = await collection.orderByTitle(endAtDocument: bSnap).get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), - isA() - .having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'B'), ], ); }); @@ -327,10 +308,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), - isA() - .having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'B'), ], ); }); @@ -344,14 +323,12 @@ void main() { final bSnap = await b.get(); - final querySnap = - await collection.orderByTitle(endBeforeDocument: bSnap).get(); + final querySnap = await collection.orderByTitle(endBeforeDocument: bSnap).get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'A'), ], ); }); @@ -455,20 +432,15 @@ void main() { ), ); - final querySnap = await collection - .whereGenre(arrayContains: 'bar') - .orderByTitle() - .get(); + final querySnap = await collection.whereGenre(arrayContains: 'bar').orderByTitle().get(); expect( querySnap.docs.map((e) => e.data.title), ['B', 'C'], ); - final querySnap2 = await collection - .whereTags(arrayContains: 'serious') - .orderByTitle() - .get(); + final querySnap2 = + await collection.whereTags(arrayContains: 'serious').orderByTitle().get(); expect( querySnap2.docs.map((e) => e.data.title), @@ -506,8 +478,7 @@ void main() { await collection.doc('B').set(createMovie(title: 'title')); await collection.doc('C').set(createMovie(title: 'title')); - final querySnap = - await collection.orderByDocumentId(startAt: 'B').get(); + final querySnap = await collection.orderByDocumentId(startAt: 'B').get(); expect( querySnap.docs, @@ -525,8 +496,7 @@ void main() { await collection.doc('B').set(createMovie(title: 'title')); await collection.doc('C').set(createMovie(title: 'title')); - final querySnap = - await collection.whereDocumentId(isEqualTo: 'B').get(); + final querySnap = await collection.whereDocumentId(isEqualTo: 'B').get(); expect( querySnap.docs, @@ -539,15 +509,11 @@ void main() { group('where', () { test('supports field renaming', () async { - final collection = - await initializeTest(AdvancedJsonCollectionReference()); + final collection = await initializeTest(AdvancedJsonCollectionReference()); - await collection - .add(AdvancedJson(firstName: 'John', lastName: 'Doe')); - await collection - .add(AdvancedJson(firstName: 'John', lastName: 'Smith')); - await collection - .add(AdvancedJson(firstName: 'Mike', lastName: 'Doe')); + await collection.add(AdvancedJson(firstName: 'John', lastName: 'Doe')); + await collection.add(AdvancedJson(firstName: 'John', lastName: 'Smith')); + await collection.add(AdvancedJson(firstName: 'Mike', lastName: 'Doe')); expect( await collection.reference @@ -589,16 +555,12 @@ void main() { group('orderBy', () { test('supports field renaming', () async { - final collection = - await initializeTest(AdvancedJsonCollectionReference()); + final collection = await initializeTest(AdvancedJsonCollectionReference()); await collection.add(AdvancedJson(firstName: 'A', lastName: 'A')); - await collection - .add(AdvancedJson(firstName: 'John', lastName: 'Doe')); - await collection - .add(AdvancedJson(firstName: 'John', lastName: 'Smith')); - await collection - .add(AdvancedJson(firstName: 'Mike', lastName: 'Doe')); + await collection.add(AdvancedJson(firstName: 'John', lastName: 'Doe')); + await collection.add(AdvancedJson(firstName: 'John', lastName: 'Smith')); + await collection.add(AdvancedJson(firstName: 'Mike', lastName: 'Doe')); expect( await collection.reference @@ -646,10 +608,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'B'), - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }, @@ -668,10 +628,8 @@ void main() { await collection.add(createMovie(title: 'C', likes: 1)); await collection.add(createMovie(title: 'C', likes: 2)); - final querySnap = await collection - .orderByTitle(startAt: 'B') - .orderByLikes(startAt: 2) - .get(); + final querySnap = + await collection.orderByTitle(startAt: 'B').orderByLikes(startAt: 2).get(); expect( querySnap.docs, @@ -700,16 +658,13 @@ void main() { final bSnap = await b.get(); - final querySnap = - await collection.orderByTitle(startAtDocument: bSnap).get(); + final querySnap = await collection.orderByTitle(startAtDocument: bSnap).get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'B'), - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }); @@ -723,14 +678,12 @@ void main() { await collection.add(createMovie(title: 'B')); await collection.add(createMovie(title: 'C')); - final querySnap = - await collection.orderByTitle(startAfter: 'B').get(); + final querySnap = await collection.orderByTitle(startAfter: 'B').get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }); @@ -744,14 +697,12 @@ void main() { final bSnap = await b.get(); - final querySnap = - await collection.orderByTitle(startAfterDocument: bSnap).get(); + final querySnap = await collection.orderByTitle(startAfterDocument: bSnap).get(); expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }); @@ -769,10 +720,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'A'), - isA() - .having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'A'), + isA().having((d) => d.data.title, 'data.title', 'B'), ], ); }); @@ -789,10 +738,8 @@ void main() { expect( querySnap.docs, [ - isA() - .having((d) => d.data.title, 'data.title', 'B'), - isA() - .having((d) => d.data.title, 'data.title', 'C'), + isA().having((d) => d.data.title, 'data.title', 'B'), + isA().having((d) => d.data.title, 'data.title', 'C'), ], ); }); @@ -956,9 +903,7 @@ void main() { test('overrides ==', () { expect( MovieCollectionReference().doc('123').comments, - MovieCollectionReference(FirebaseFirestore.instance) - .doc('123') - .comments, + MovieCollectionReference(FirebaseFirestore.instance).doc('123').comments, ); expect( MovieCollectionReference().doc('123').comments, @@ -985,11 +930,10 @@ void main() { await collection.add(Enums(id: 'B', enumValue: TestEnum.two)); await collection.add(Enums(id: 'C', enumValue: TestEnum.two)); - final querySnap = - await collection.whereEnumValue(isEqualTo: TestEnum.two).get(); + final querySnap = await collection.whereEnumValue(isEqualTo: TestEnum.two).get(); expect( - querySnap.docs.map((e) => e.data.id), + (querySnap.docs.map((e) => e.data.id).toList()..sort()), ['B', 'C'], ); }); @@ -1001,12 +945,10 @@ void main() { await collection.add(Enums(id: 'B', nullableEnumValue: TestEnum.two)); await collection.add(Enums(id: 'C', nullableEnumValue: TestEnum.two)); - final querySnap = await collection - .whereNullableEnumValue(isEqualTo: TestEnum.two) - .get(); + final querySnap = await collection.whereNullableEnumValue(isEqualTo: TestEnum.two).get(); expect( - querySnap.docs.map((e) => e.data.id), + (querySnap.docs.map((e) => e.data.id).toList()..sort()), ['B', 'C'], ); }); @@ -1014,18 +956,14 @@ void main() { test('enumList', () async { final collection = await initializeTest(EnumsCollectionReference()); - await collection - .add(Enums(id: 'A', enumList: [TestEnum.one, TestEnum.three])); - await collection - .add(Enums(id: 'B', enumList: [TestEnum.two, TestEnum.three])); - await collection - .add(Enums(id: 'C', enumList: [TestEnum.two, TestEnum.three])); + await collection.add(Enums(id: 'A', enumList: [TestEnum.one, TestEnum.three])); + await collection.add(Enums(id: 'B', enumList: [TestEnum.two, TestEnum.three])); + await collection.add(Enums(id: 'C', enumList: [TestEnum.two, TestEnum.three])); - final querySnap = - await collection.whereEnumList(arrayContains: TestEnum.two).get(); + final querySnap = await collection.whereEnumList(arrayContains: TestEnum.two).get(); expect( - querySnap.docs.map((e) => e.data.id), + (querySnap.docs.map((e) => e.data.id).toList()..sort()), ['B', 'C'], ); }); @@ -1043,12 +981,10 @@ void main() { Enums(id: 'C', nullableEnumList: [TestEnum.two, TestEnum.three]), ); - final querySnap = await collection - .whereNullableEnumList(arrayContains: TestEnum.two) - .get(); + final querySnap = await collection.whereNullableEnumList(arrayContains: TestEnum.two).get(); expect( - querySnap.docs.map((e) => e.data.id), + (querySnap.docs.map((e) => e.data.id).toList()..sort()), ['B', 'C'], ); }); diff --git a/packages/cloud_firestore_odm/example/integration_test/common.dart b/packages/cloud_firestore_odm/example/integration_test/common.dart index c033ef9..1cb0846 100644 --- a/packages/cloud_firestore_odm/example/integration_test/common.dart +++ b/packages/cloud_firestore_odm/example/integration_test/common.dart @@ -9,15 +9,10 @@ import 'package:cloud_firestore_odm_example/movie.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:mockito/mockito.dart'; -Future - initializeTest>( - T ref, -) async { +Future initializeTest>(T ref) async { final snapshot = await ref.reference.get(); - await Future.wait( - snapshot.docs.map((e) => e.reference.delete()), - ); + await Future.wait(snapshot.docs.map((e) => e.reference.delete())); return ref; } 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 465faaf..c034769 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 @@ -35,19 +35,13 @@ void main() { await collection.doc('123').set(createMovie(title: 'title')); - expect( - await collection.doc('123').get().then((e) => e.exists), - true, - ); + expect(await collection.doc('123').get().then((e) => e.exists), true); await FirebaseFirestore.instance.runTransaction((transaction) async { collection.doc('123').transactionDelete(transaction); }); - expect( - await collection.doc('123').get().then((e) => e.exists), - false, - ); + expect(await collection.doc('123').get().then((e) => e.exists), false); }); test('batch', () async { @@ -86,11 +80,7 @@ void main() { 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, - ], + [updatedTitle, isA().having((e) => e.title, newTitle, newTitle), false], ); }); @@ -99,24 +89,21 @@ void main() { await collection.doc('123').set(createMovie(title: 'title')); - expect( - await collection.doc('123').get().then((e) => e.exists), - true, - ); + expect(await collection.doc('123').get().then((e) => e.exists), true); await collection.doc('123').delete(); - expect( - await collection.doc('123').get().then((e) => e.exists), - false, - ); + expect(await collection.doc('123').get().then((e) => e.exists), false); }); test('reference', () async { expect( MovieCollectionReference().doc('123').reference, - isA>() - .having((e) => e.path, 'path', 'firestore-example-app/123'), + isA>().having( + (e) => e.path, + 'path', + 'firestore-example-app/123', + ), ); expect( @@ -137,16 +124,10 @@ void main() { await collection.doc('123').get(); expect( - await collection - .doc('123') - .get(const GetOptions(source: Source.cache)), + await collection.doc('123').get(const GetOptions(source: Source.cache)), isA() .having((e) => e.data?.title, 'data.title', 'title') - .having( - (e) => e.metadata.isFromCache, - 'metadata.isFromCache', - true, - ), + .having((e) => e.metadata.isFromCache, 'metadata.isFromCache', true), ); }); }); @@ -172,8 +153,7 @@ void main() { expect( await stream.next, - isA() - .having((e) => e.exists, 'exists', false), + isA().having((e) => e.exists, 'exists', false), ); await collection.doc('123').set(createMovie(title: 'title')); @@ -191,7 +171,9 @@ void main() { test('allows modifying a single property of an object', () async { final ref = await initializeTest(moviesRef); - await ref.doc('123').set( + await ref + .doc('123') + .set( Movie( genre: [], likes: 42, @@ -248,17 +230,12 @@ void main() { ); await FirebaseFirestore.instance.runTransaction((transaction) async { - ref.doc('123').transactionSet( - transaction, - createMovie(title: 'Foo'), - ); + ref.doc('123').transactionSet(transaction, createMovie(title: 'Foo')); }); expect( await ref.doc('123').get().then((e) => e.data), - isA() - .having((e) => e.rated, 'rated', '') - .having((e) => e.title, 'title', 'Foo'), + isA().having((e) => e.rated, 'rated', '').having((e) => e.title, 'title', 'Foo'), ); }); }); @@ -286,12 +263,9 @@ void main() { ); }); - test('asserts that we cannot specify both FieldValue and normal value', - () async { + test('asserts that we cannot specify both FieldValue and normal value', () async { expect( - () => moviesRef - .doc('123') - .update(likes: 10, likesFieldValue: FieldValue.increment(10)), + () => moviesRef.doc('123').update(likes: 10, likesFieldValue: FieldValue.increment(10)), throwsAssertionError, ); }); @@ -299,7 +273,9 @@ void main() { test('allows modifying only one property of an object', () async { final ref = await initializeTest(moviesRef); - await ref.doc('123').set( + await ref + .doc('123') + .set( Movie( genre: [], likes: 42, @@ -324,9 +300,7 @@ void main() { .having((e) => e.year, 'year', 0), ); - await ref.doc('123').update( - genre: ['genre'], - ); + await ref.doc('123').update(genre: ['genre']); expect( await ref.doc('123').get().then((e) => e.data), @@ -344,7 +318,9 @@ void main() { test('can set a property to null', () async { final ref = await initializeTest(moviesRef); - await ref.doc('123').set( + await ref + .doc('123') + .set( Movie( genre: [], likes: 42, @@ -369,7 +345,9 @@ void main() { .having((e) => e.year, 'year', 0), ); - await ref.doc('123').update( + await ref + .doc('123') + .update( // ignore: avoid_redundant_argument_values, false positive genre: null, ); @@ -408,59 +386,40 @@ void main() { await collection.doc('123').set(createMovie(title: 'Foo')); - expect( - await collection.doc().get().then((d) => d.exists), - false, - ); - expect( - await collection.doc('123').get().then((d) => d.exists), - true, - ); + expect(await collection.doc().get().then((d) => d.exists), false); + expect(await collection.doc('123').get().then((d) => d.exists), true); }); }); group('root document reference', () { - test( - 'can make fromJson optional if model is annotated by JsonSerializable', - () async { + test('can make fromJson optional if model is annotated by JsonSerializable', () async { final collection = await initializeTest(optionalJsonRef); await collection.doc('123').set(OptionalJson(42)); - expect( - await collection.doc('123').get().then((value) => value.data?.value), - 42, - ); + expect(await collection.doc('123').get().then((value) => value.data?.value), 42); }); test( - 'if fromJson/toJson are specified, use them even if the model is annotated by JsonSerializable', - () async { - final collection = await initializeTest(mixedJsonRef); + 'if fromJson/toJson are specified, use them even if the model is annotated by JsonSerializable', + () async { + final collection = await initializeTest(mixedJsonRef); - await collection.doc('123').set(MixedJson(42)); + await collection.doc('123').set(MixedJson(42)); - final rawSnapshot = await FirebaseFirestore.instance - .collection('root') - .doc('123') - .get(); + final rawSnapshot = await FirebaseFirestore.instance.collection('root').doc('123').get(); - expect(rawSnapshot.data(), {'foo': 42}); - expect( - await collection.doc('123').get().then((value) => value.data?.value), - 42, - ); - }); + expect(rawSnapshot.data(), {'foo': 42}); + expect(await collection.doc('123').get().then((value) => value.data?.value), 42); + }, + ); test('overrides ==', () { expect( MovieCollectionReference().doc('123'), MovieCollectionReference(FirebaseFirestore.instance).doc('123'), ); - expect( - MovieCollectionReference().doc('123'), - isNot(MovieCollectionReference().doc('456')), - ); + expect(MovieCollectionReference().doc('123'), isNot(MovieCollectionReference().doc('456'))); expect( MovieCollectionReference(customFirestore).doc('123'), @@ -477,10 +436,7 @@ void main() { test('overrides ==', () { expect( MovieCollectionReference().doc('123').comments.doc('123'), - MovieCollectionReference(FirebaseFirestore.instance) - .doc('123') - .comments - .doc('123'), + MovieCollectionReference(FirebaseFirestore.instance).doc('123').comments.doc('123'), ); expect( MovieCollectionReference().doc('123').comments.doc('123'), @@ -492,21 +448,12 @@ void main() { ); expect( - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .doc('123'), + MovieCollectionReference(customFirestore).doc('123').comments.doc('123'), isNot(MovieCollectionReference().doc('123').comments.doc('123')), ); expect( - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .doc('123'), - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .doc('123'), + MovieCollectionReference(customFirestore).doc('123').comments.doc('123'), + MovieCollectionReference(customFirestore).doc('123').comments.doc('123'), ); }); }); diff --git a/packages/cloud_firestore_odm/example/integration_test/firestore_builder_test.dart b/packages/cloud_firestore_odm/example/integration_test/firestore_builder_test.dart index 0e83f66..9b6611e 100644 --- a/packages/cloud_firestore_odm/example/integration_test/firestore_builder_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/firestore_builder_test.dart @@ -23,8 +23,7 @@ void main() { return ListView( children: [ - for (final doc in snapshot.requireData.docs) - Text(doc.data.title), + for (final doc in snapshot.requireData.docs) Text(doc.data.title), ], ); }, @@ -49,7 +48,7 @@ void main() { ); } - group('$FirestoreBuilder', () { + group('FirestoreBuilder', () { testWidgets('listens to documents', (tester) async { final collection = await initializeTest(MovieCollectionReference()); @@ -69,8 +68,7 @@ void main() { expect(find.text('Foo'), findsOneWidget); }); - testWidgets('emits errored snapshot when failed to decode a value', - (tester) async { + testWidgets('emits errored snapshot when failed to decode a value', (tester) async { final collection = await initializeTest(MovieCollectionReference()); await FirebaseFirestore.instance @@ -146,8 +144,7 @@ void main() { expect(find.text('A'), findsOneWidget); expect(find.text('B'), findsOneWidget); }); - testWidgets( - 'does not go back to loading if rebuilding the widget with the same query', + testWidgets('does not go back to loading if rebuilding the widget with the same query', (tester) async { final collection = await initializeTest(MovieCollectionReference()); diff --git a/packages/cloud_firestore_odm/example/integration_test/freezed_test.dart b/packages/cloud_firestore_odm/example/integration_test/freezed_test.dart index 461202b..faed47d 100644 --- a/packages/cloud_firestore_odm/example/integration_test/freezed_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/freezed_test.dart @@ -2,12 +2,21 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm_example/integration/freezed.dart'; +import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_test/flutter_test.dart'; import 'common.dart'; +import 'firebase_options.dart'; void main() { + setUpAll(() async { + await Firebase.initializeApp( + options: DefaultFirebaseOptions.currentPlatform, + ); + FirebaseFirestore.instance.useFirestoreEmulator('localhost', 8080); + }); test('supports field renaming', () async { final collection = await initializeTest(PersonCollectionReference()); @@ -55,12 +64,13 @@ void main() { await aRef.update(firstName: 'A2', lastName: 'B2'); expect( - await aRef.reference - .withConverter>( - fromFirestore: (value, _) => value.data()!, - toFirestore: (value, _) => value, - ) - .get(), + (await aRef.reference + .withConverter>( + fromFirestore: (value, _) => value.data()!, + toFirestore: (value, _) => value, + ) + .get()) + .data(), { 'first_name': 'A2', 'LAST_NAME': 'B2', diff --git a/packages/cloud_firestore_odm/example/integration_test/path_test.dart b/packages/cloud_firestore_odm/example/integration_test/path_test.dart index cf4650f..fadcc03 100644 --- a/packages/cloud_firestore_odm/example/integration_test/path_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/path_test.dart @@ -21,8 +21,7 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data.value, 'data.value', 42), + isA().having((e) => e.data.value, 'data.value', 42), ]); }); @@ -36,8 +35,7 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data.value, 'data.value', 42), + isA().having((e) => e.data.value, 'data.value', 42), ]); }); }); @@ -53,15 +51,12 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data.value, 'data.value', 42), + isA().having((e) => e.data.value, 'data.value', 42), ]); }); - test('can be manually specified through the Collection annotation', - () async { - final collection = - await initializeTest(rootRef.doc('123').thisIsACustomName); + test('can be manually specified through the Collection annotation', () async { + final collection = await initializeTest(rootRef.doc('123').thisIsACustomName); await FirebaseFirestore.instance .collection('root/123/custom-sub-name') @@ -70,18 +65,15 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data.value, 'data.value', 42), + isA().having((e) => e.data.value, 'data.value', 42), ]); }); }); }); group('collection class prefix', () { - test('can be manually specified through the Collection annotation', - () async { - final collection = - await initializeTest(rootRef.doc('123').customClassPrefix); + test('can be manually specified through the Collection annotation', () async { + final collection = await initializeTest(rootRef.doc('123').customClassPrefix); await FirebaseFirestore.instance .collection('root/123/custom-class-prefix') @@ -90,8 +82,7 @@ void main() { final snapshot = await collection.get(); expect(snapshot.docs, [ - isA() - .having((e) => e.data?.value, 'data.value', 42), + isA().having((e) => e.data?.value, 'data.value', 42), ]); }); }); diff --git a/packages/cloud_firestore_odm/example/integration_test/query_reference_test.dart b/packages/cloud_firestore_odm/example/integration_test/query_reference_test.dart index 9426839..4f53142 100644 --- a/packages/cloud_firestore_odm/example/integration_test/query_reference_test.dart +++ b/packages/cloud_firestore_odm/example/integration_test/query_reference_test.dart @@ -2,15 +2,11 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:typed_data'; - import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:cloud_firestore_odm_example/integration/named_query.dart'; import 'package:cloud_firestore_odm_example/integration/query.dart'; import 'package:cloud_firestore_odm_example/movie.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:http/http.dart' as http; import 'common.dart'; @@ -38,10 +34,7 @@ void main() { MovieCollectionReference().limit(1), MovieCollectionReference(FirebaseFirestore.instance).limit(1), ); - expect( - MovieCollectionReference().limit(1), - isNot(MovieCollectionReference().limit(2)), - ); + expect(MovieCollectionReference().limit(1), isNot(MovieCollectionReference().limit(2))); expect( MovieCollectionReference(customFirestore).limit(1), @@ -58,10 +51,7 @@ void main() { test('overrides ==', () { expect( MovieCollectionReference().doc('123').comments.limit(1), - MovieCollectionReference(FirebaseFirestore.instance) - .doc('123') - .comments - .limit(1), + MovieCollectionReference(FirebaseFirestore.instance).doc('123').comments.limit(1), ); expect( MovieCollectionReference().doc('123').comments.limit(1), @@ -73,21 +63,12 @@ void main() { ); expect( - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .limit(1), + MovieCollectionReference(customFirestore).doc('123').comments.limit(1), isNot(MovieCollectionReference().doc('123').comments.limit(1)), ); expect( - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .limit(1), - MovieCollectionReference(customFirestore) - .doc('123') - .comments - .limit(1), + MovieCollectionReference(customFirestore).doc('123').comments.limit(1), + MovieCollectionReference(customFirestore).doc('123').comments.limit(1), ); }); }); @@ -99,8 +80,7 @@ void main() { await ref.add(DurationQuery(const Duration(days: 2))); await ref.add(DurationQuery(const Duration(days: 3))); - final snapshot = - await ref.orderByDuration(startAt: const Duration(days: 2)).get(); + final snapshot = await ref.orderByDuration(startAt: const Duration(days: 2)).get(); expect(snapshot.docs.length, 2); @@ -130,9 +110,7 @@ void main() { await ref.add(TimestampQuery(Timestamp.fromDate(DateTime(2000)))); await ref.add(TimestampQuery(Timestamp.fromDate(DateTime(2010)))); - final snapshot = await ref - .orderByTime(startAt: Timestamp.fromDate(DateTime(2000))) - .get(); + final snapshot = await ref.orderByTime(startAt: Timestamp.fromDate(DateTime(2000))).get(); expect(snapshot.docs.length, 2); @@ -147,8 +125,7 @@ void main() { await ref.add(GeoPointQuery(const GeoPoint(20, 0))); await ref.add(GeoPointQuery(const GeoPoint(20, 0))); - final snapshot = - await ref.orderByPoint(startAt: const GeoPoint(20, 0)).get(); + final snapshot = await ref.orderByPoint(startAt: const GeoPoint(20, 0)).get(); expect(snapshot.docs.length, 2); @@ -161,15 +138,9 @@ void main() { () async { final ref = await initializeTest(documentReferenceRef); - await ref.add( - DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/a')), - ); - await ref.add( - DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/b')), - ); - await ref.add( - DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/c')), - ); + await ref.add(DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/a'))); + await ref.add(DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/b'))); + await ref.add(DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/c'))); final snapshot = await ref .orderByRef(startAt: FirebaseFirestore.instance.doc('foo/b')) @@ -177,46 +148,10 @@ void main() { expect(snapshot.docs.length, 2); - expect( - snapshot.docs[0].data.ref, - FirebaseFirestore.instance.doc('foo/b'), - ); - expect( - snapshot.docs[1].data.ref, - FirebaseFirestore.instance.doc('foo/c'), - ); + expect(snapshot.docs[0].data.ref, FirebaseFirestore.instance.doc('foo/b')); + expect(snapshot.docs[1].data.ref, FirebaseFirestore.instance.doc('foo/c')); }, skip: 'Blocked by FlutterFire support for querying document references', ); }); - - group('FirebaeFirestore.myCustomNamedQuery()', () { - Future loadBundleSetup() async { - // endpoint serves a bundle with 3 documents each containing - // a 'number' property that increments in value 1-3. - final url = Uri.https('api.rnfirebase.io', '/firestore/bundle-4'); - final response = await http.get(url); - final string = response.body; - return Uint8List.fromList(string.codeUnits); - } - - test('myCustomNamedQuery() successful', () async { - final buffer = await loadBundleSetup(); - final task = FirebaseFirestore.instance.loadBundle(buffer); - - // ensure the bundle has been completely cached - await task.stream.last; - - // namedQuery 'named-bundle-test' which returns a QuerySnaphot of the same 3 documents - // with 'number' property - final snapshot = await FirebaseFirestore.instance.namedBundleTest4Get( - options: const GetOptions(source: Source.cache), - ); - - expect( - snapshot.docs.map((document) => document.data.number), - everyElement(anyOf(1, 2, 3)), - ); - }); - }); } diff --git a/packages/cloud_firestore_odm/example/lib/integration.dart b/packages/cloud_firestore_odm/example/lib/integration.dart index 1570420..c0a69f3 100644 --- a/packages/cloud_firestore_odm/example/lib/integration.dart +++ b/packages/cloud_firestore_odm/example/lib/integration.dart @@ -6,14 +6,14 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:json_annotation/json_annotation.dart'; +part 'integration.firebase.dart'; part 'integration.g.dart'; @JsonSerializable() class EmptyModel { EmptyModel(); - factory EmptyModel.fromJson(Map json) => - _$EmptyModelFromJson(json); + factory EmptyModel.fromJson(Map json) => _$EmptyModelFromJson(json); Map toJson() => _$EmptyModelToJson(this); } diff --git a/packages/cloud_firestore_odm/example/lib/integration.firebase.dart b/packages/cloud_firestore_odm/example/lib/integration.firebase.dart new file mode 100644 index 0000000..66bd9cb --- /dev/null +++ b/packages/cloud_firestore_odm/example/lib/integration.firebase.dart @@ -0,0 +1,3023 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'integration.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class AdvancedJsonCollectionReference + implements + AdvancedJsonQuery, + FirestoreCollectionReference { + factory AdvancedJsonCollectionReference([FirebaseFirestore? firestore]) = + _$AdvancedJsonCollectionReference; + + static AdvancedJson fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$AdvancedJsonFromJson(snapshot.data()!); + } + + static Map toFirestore( + AdvancedJson value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + AdvancedJsonDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(AdvancedJson value); +} + +class _$AdvancedJsonCollectionReference extends _$AdvancedJsonQuery + implements AdvancedJsonCollectionReference { + factory _$AdvancedJsonCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$AdvancedJsonCollectionReference._( + firestore + .collection('firestore-example-app/test/advanced') + .withConverter( + fromFirestore: AdvancedJsonCollectionReference.fromFirestore, + toFirestore: AdvancedJsonCollectionReference.toFirestore, + ), + ); + } + + _$AdvancedJsonCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + AdvancedJsonDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return AdvancedJsonDocumentReference(reference.doc(id)); + } + + @override + Future add(AdvancedJson value) { + return reference + .add(value) + .then((ref) => AdvancedJsonDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$AdvancedJsonCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class AdvancedJsonDocumentReference + extends + FirestoreDocumentReference { + factory AdvancedJsonDocumentReference( + DocumentReference reference, + ) = _$AdvancedJsonDocumentReference; + + DocumentReference get reference; + + /// A reference to the [AdvancedJsonCollectionReference] containing this document. + AdvancedJsonCollectionReference get parent { + return _$AdvancedJsonCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + AdvancedJson model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + AdvancedJson model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + AdvancedJson model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String? firstName, + FieldValue firstNameFieldValue, + String? lastName, + FieldValue lastNameFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String? firstName, + FieldValue firstNameFieldValue, + 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 + implements AdvancedJsonDocumentReference { + _$AdvancedJsonDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [AdvancedJsonCollectionReference] containing this document. + AdvancedJsonCollectionReference get parent { + return _$AdvancedJsonCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(AdvancedJsonDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(AdvancedJsonDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(AdvancedJsonDocumentSnapshot._); + } + + Future set( + AdvancedJson model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) async { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + AdvancedJson model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + AdvancedJson model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? firstName = _sentinel, + FieldValue? firstNameFieldValue, + Object? lastName = _sentinel, + FieldValue? lastNameFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class AdvancedJsonQuery + implements QueryReference { + @override + AdvancedJsonQuery limit(int limit); + + @override + AdvancedJsonQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + AdvancedJsonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + AdvancedJsonQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + AdvancedJsonQuery whereFirstName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + AdvancedJsonQuery whereLastName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + AdvancedJsonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + AdvancedJsonDocumentSnapshot? startAtDocument, + AdvancedJsonDocumentSnapshot? endAtDocument, + AdvancedJsonDocumentSnapshot? endBeforeDocument, + AdvancedJsonDocumentSnapshot? startAfterDocument, + }); + + AdvancedJsonQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + AdvancedJsonDocumentSnapshot? startAtDocument, + AdvancedJsonDocumentSnapshot? endAtDocument, + AdvancedJsonDocumentSnapshot? endBeforeDocument, + AdvancedJsonDocumentSnapshot? startAfterDocument, + }); + + AdvancedJsonQuery orderByFirstName({ + bool descending = false, + String? startAt, + String? startAfter, + String? endAt, + String? endBefore, + AdvancedJsonDocumentSnapshot? startAtDocument, + AdvancedJsonDocumentSnapshot? endAtDocument, + AdvancedJsonDocumentSnapshot? endBeforeDocument, + AdvancedJsonDocumentSnapshot? startAfterDocument, + }); + + AdvancedJsonQuery orderByLastName({ + bool descending = false, + String? startAt, + String? startAfter, + String? endAt, + String? endBefore, + AdvancedJsonDocumentSnapshot? startAtDocument, + AdvancedJsonDocumentSnapshot? endAtDocument, + AdvancedJsonDocumentSnapshot? endBeforeDocument, + AdvancedJsonDocumentSnapshot? startAfterDocument, + }); +} + +class _$AdvancedJsonQuery + extends QueryReference + implements AdvancedJsonQuery { + _$AdvancedJsonQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + AdvancedJsonQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(AdvancedJsonQuerySnapshot._fromQuerySnapshot); + } + + @override + AdvancedJsonQuery limit(int limit) { + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + AdvancedJsonQuery limitToLast(int limit) { + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + AdvancedJsonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + AdvancedJsonQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + AdvancedJsonQuery whereFirstName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$AdvancedJsonFieldMap['firstName']!, + isEqualTo: isEqualTo != _sentinel + ? _$AdvancedJsonPerFieldToJson.firstName(isEqualTo as String?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$AdvancedJsonPerFieldToJson.firstName(isNotEqualTo as String?) + : null, + isLessThan: isLessThan != null + ? _$AdvancedJsonPerFieldToJson.firstName(isLessThan as String?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$AdvancedJsonPerFieldToJson.firstName( + isLessThanOrEqualTo as String?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$AdvancedJsonPerFieldToJson.firstName(isGreaterThan as String?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$AdvancedJsonPerFieldToJson.firstName( + isGreaterThanOrEqualTo as String?, + ) + : null, + whereIn: whereIn?.map((e) => _$AdvancedJsonPerFieldToJson.firstName(e)), + whereNotIn: whereNotIn?.map( + (e) => _$AdvancedJsonPerFieldToJson.firstName(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + AdvancedJsonQuery whereLastName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$AdvancedJsonFieldMap['lastName']!, + isEqualTo: isEqualTo != _sentinel + ? _$AdvancedJsonPerFieldToJson.lastName(isEqualTo as String?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$AdvancedJsonPerFieldToJson.lastName(isNotEqualTo as String?) + : null, + isLessThan: isLessThan != null + ? _$AdvancedJsonPerFieldToJson.lastName(isLessThan as String?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$AdvancedJsonPerFieldToJson.lastName( + isLessThanOrEqualTo as String?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$AdvancedJsonPerFieldToJson.lastName(isGreaterThan as String?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$AdvancedJsonPerFieldToJson.lastName( + isGreaterThanOrEqualTo as String?, + ) + : null, + whereIn: whereIn?.map((e) => _$AdvancedJsonPerFieldToJson.lastName(e)), + whereNotIn: whereNotIn?.map( + (e) => _$AdvancedJsonPerFieldToJson.lastName(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + AdvancedJsonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + AdvancedJsonDocumentSnapshot? startAtDocument, + AdvancedJsonDocumentSnapshot? endAtDocument, + AdvancedJsonDocumentSnapshot? endBeforeDocument, + AdvancedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + AdvancedJsonQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + AdvancedJsonDocumentSnapshot? startAtDocument, + AdvancedJsonDocumentSnapshot? endAtDocument, + AdvancedJsonDocumentSnapshot? endBeforeDocument, + AdvancedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + AdvancedJsonQuery orderByFirstName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + AdvancedJsonDocumentSnapshot? startAtDocument, + AdvancedJsonDocumentSnapshot? endAtDocument, + AdvancedJsonDocumentSnapshot? endBeforeDocument, + AdvancedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$AdvancedJsonFieldMap['firstName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$AdvancedJsonPerFieldToJson.firstName(startAt as String?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$AdvancedJsonPerFieldToJson.firstName(startAfter as String?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$AdvancedJsonPerFieldToJson.firstName(endAt as String?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$AdvancedJsonPerFieldToJson.firstName(endBefore as String?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + AdvancedJsonQuery orderByLastName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + AdvancedJsonDocumentSnapshot? startAtDocument, + AdvancedJsonDocumentSnapshot? endAtDocument, + AdvancedJsonDocumentSnapshot? endBeforeDocument, + AdvancedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$AdvancedJsonFieldMap['lastName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$AdvancedJsonPerFieldToJson.lastName(startAt as String?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$AdvancedJsonPerFieldToJson.lastName(startAfter as String?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$AdvancedJsonPerFieldToJson.lastName(endAt as String?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$AdvancedJsonPerFieldToJson.lastName(endBefore as String?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$AdvancedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$AdvancedJsonQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class AdvancedJsonDocumentSnapshot + extends FirestoreDocumentSnapshot { + AdvancedJsonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + AdvancedJsonDocumentReference get reference { + return AdvancedJsonDocumentReference(snapshot.reference); + } + + @override + final AdvancedJson? data; +} + +class AdvancedJsonQuerySnapshot + extends + FirestoreQuerySnapshot< + AdvancedJson, + AdvancedJsonQueryDocumentSnapshot + > { + AdvancedJsonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory AdvancedJsonQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(AdvancedJsonQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, AdvancedJsonDocumentSnapshot._); + }).toList(); + + return AdvancedJsonQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + AdvancedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class AdvancedJsonQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements AdvancedJsonDocumentSnapshot { + AdvancedJsonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final AdvancedJson data; + + @override + AdvancedJsonDocumentReference get reference { + return AdvancedJsonDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class _PrivateAdvancedJsonCollectionReference + implements + _PrivateAdvancedJsonQuery, + FirestoreCollectionReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQuerySnapshot + > { + factory _PrivateAdvancedJsonCollectionReference([ + FirebaseFirestore? firestore, + ]) = _$_PrivateAdvancedJsonCollectionReference; + + static _PrivateAdvancedJson fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$PrivateAdvancedJsonFromJson(snapshot.data()!); + } + + static Map toFirestore( + _PrivateAdvancedJson value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference<_PrivateAdvancedJson> get reference; + + @override + _PrivateAdvancedJsonDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future<_PrivateAdvancedJsonDocumentReference> add(_PrivateAdvancedJson value); +} + +class _$_PrivateAdvancedJsonCollectionReference + extends _$_PrivateAdvancedJsonQuery + implements _PrivateAdvancedJsonCollectionReference { + factory _$_PrivateAdvancedJsonCollectionReference([ + FirebaseFirestore? firestore, + ]) { + firestore ??= FirebaseFirestore.instance; + + return _$_PrivateAdvancedJsonCollectionReference._( + firestore + .collection('firestore-example-app/test/private-advanced') + .withConverter( + fromFirestore: + _PrivateAdvancedJsonCollectionReference.fromFirestore, + toFirestore: _PrivateAdvancedJsonCollectionReference.toFirestore, + ), + ); + } + + _$_PrivateAdvancedJsonCollectionReference._( + CollectionReference<_PrivateAdvancedJson> reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference<_PrivateAdvancedJson> get reference => + super.reference as CollectionReference<_PrivateAdvancedJson>; + + @override + _PrivateAdvancedJsonDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return _PrivateAdvancedJsonDocumentReference(reference.doc(id)); + } + + @override + Future<_PrivateAdvancedJsonDocumentReference> add( + _PrivateAdvancedJson value, + ) { + return reference + .add(value) + .then((ref) => _PrivateAdvancedJsonDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$_PrivateAdvancedJsonCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class _PrivateAdvancedJsonDocumentReference + extends + FirestoreDocumentReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonDocumentSnapshot + > { + factory _PrivateAdvancedJsonDocumentReference( + DocumentReference<_PrivateAdvancedJson> reference, + ) = _$_PrivateAdvancedJsonDocumentReference; + + DocumentReference<_PrivateAdvancedJson> get reference; + + /// A reference to the [_PrivateAdvancedJsonCollectionReference] containing this document. + _PrivateAdvancedJsonCollectionReference get parent { + return _$_PrivateAdvancedJsonCollectionReference(reference.firestore); + } + + @override + Stream<_PrivateAdvancedJsonDocumentSnapshot> snapshots(); + + @override + Future<_PrivateAdvancedJsonDocumentSnapshot> get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + _PrivateAdvancedJson model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + _PrivateAdvancedJson model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + _PrivateAdvancedJson model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String? firstName, + FieldValue firstNameFieldValue, + String? lastName, + FieldValue lastNameFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String? firstName, + FieldValue firstNameFieldValue, + 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 + extends + FirestoreDocumentReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonDocumentSnapshot + > + implements _PrivateAdvancedJsonDocumentReference { + _$_PrivateAdvancedJsonDocumentReference(this.reference); + + @override + final DocumentReference<_PrivateAdvancedJson> reference; + + /// A reference to the [_PrivateAdvancedJsonCollectionReference] containing this document. + _PrivateAdvancedJsonCollectionReference get parent { + return _$_PrivateAdvancedJsonCollectionReference(reference.firestore); + } + + @override + Stream<_PrivateAdvancedJsonDocumentSnapshot> snapshots() { + return reference.snapshots().map(_PrivateAdvancedJsonDocumentSnapshot._); + } + + @override + Future<_PrivateAdvancedJsonDocumentSnapshot> get([GetOptions? options]) { + return reference.get(options).then(_PrivateAdvancedJsonDocumentSnapshot._); + } + + @override + Future<_PrivateAdvancedJsonDocumentSnapshot> transactionGet( + Transaction transaction, + ) { + return transaction + .get(reference) + .then(_PrivateAdvancedJsonDocumentSnapshot._); + } + + Future set( + _PrivateAdvancedJson model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) async { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + _PrivateAdvancedJson model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + _PrivateAdvancedJson model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? firstName = _sentinel, + FieldValue? firstNameFieldValue, + Object? lastName = _sentinel, + FieldValue? lastNameFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class _PrivateAdvancedJsonQuery + implements + QueryReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQuerySnapshot + > { + @override + _PrivateAdvancedJsonQuery limit(int limit); + + @override + _PrivateAdvancedJsonQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + _PrivateAdvancedJsonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + _PrivateAdvancedJsonQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + _PrivateAdvancedJsonQuery whereFirstName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + _PrivateAdvancedJsonQuery whereLastName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + _PrivateAdvancedJsonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, + _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, + }); + + _PrivateAdvancedJsonQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, + _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, + }); + + _PrivateAdvancedJsonQuery orderByFirstName({ + bool descending = false, + String? startAt, + String? startAfter, + String? endAt, + String? endBefore, + _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, + _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, + }); + + _PrivateAdvancedJsonQuery orderByLastName({ + bool descending = false, + String? startAt, + String? startAfter, + String? endAt, + String? endBefore, + _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, + _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, + }); +} + +class _$_PrivateAdvancedJsonQuery + extends + QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonQuerySnapshot> + implements _PrivateAdvancedJsonQuery { + _$_PrivateAdvancedJsonQuery( + this._collection, { + required Query<_PrivateAdvancedJson> $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream<_PrivateAdvancedJsonQuerySnapshot> snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + _PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future<_PrivateAdvancedJsonQuerySnapshot> get([GetOptions? options]) { + return reference + .get(options) + .then(_PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot); + } + + @override + _PrivateAdvancedJsonQuery limit(int limit) { + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery limitToLast(int limit) { + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery whereFirstName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PrivateAdvancedJsonFieldMap['firstName']!, + isEqualTo: isEqualTo != _sentinel + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isEqualTo as String?, + ) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isNotEqualTo as String?, + ) + : null, + isLessThan: isLessThan != null + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isLessThan as String?, + ) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isLessThanOrEqualTo as String?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isGreaterThan as String?, + ) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isGreaterThanOrEqualTo as String?, + ) + : null, + whereIn: whereIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery whereLastName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PrivateAdvancedJsonFieldMap['lastName']!, + isEqualTo: isEqualTo != _sentinel + ? _$PrivateAdvancedJsonPerFieldToJson.lastName(isEqualTo as String?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isNotEqualTo as String?, + ) + : null, + isLessThan: isLessThan != null + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isLessThan as String?, + ) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isLessThanOrEqualTo as String?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isGreaterThan as String?, + ) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isGreaterThanOrEqualTo as String?, + ) + : null, + whereIn: whereIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, + _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, + _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery orderByFirstName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, + _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PrivateAdvancedJsonFieldMap['firstName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PrivateAdvancedJsonPerFieldToJson.firstName(startAt as String?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PrivateAdvancedJsonPerFieldToJson.firstName(startAfter as String?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PrivateAdvancedJsonPerFieldToJson.firstName(endAt as String?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PrivateAdvancedJsonPerFieldToJson.firstName(endBefore as String?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + _PrivateAdvancedJsonQuery orderByLastName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, + _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, + _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PrivateAdvancedJsonFieldMap['lastName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PrivateAdvancedJsonPerFieldToJson.lastName(startAt as String?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PrivateAdvancedJsonPerFieldToJson.lastName(startAfter as String?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PrivateAdvancedJsonPerFieldToJson.lastName(endAt as String?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PrivateAdvancedJsonPerFieldToJson.lastName(endBefore as String?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$_PrivateAdvancedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$_PrivateAdvancedJsonQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class _PrivateAdvancedJsonDocumentSnapshot + extends FirestoreDocumentSnapshot<_PrivateAdvancedJson> { + _PrivateAdvancedJsonDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); + + @override + final DocumentSnapshot<_PrivateAdvancedJson> snapshot; + + @override + _PrivateAdvancedJsonDocumentReference get reference { + return _PrivateAdvancedJsonDocumentReference(snapshot.reference); + } + + @override + final _PrivateAdvancedJson? data; +} + +class _PrivateAdvancedJsonQuerySnapshot + extends + FirestoreQuerySnapshot< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQueryDocumentSnapshot + > { + _PrivateAdvancedJsonQuerySnapshot._( + this.snapshot, + this.docs, + this.docChanges, + ); + + factory _PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot( + QuerySnapshot<_PrivateAdvancedJson> snapshot, + ) { + final docs = snapshot.docs + .map(_PrivateAdvancedJsonQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + _PrivateAdvancedJsonDocumentSnapshot._, + ); + }).toList(); + + return _PrivateAdvancedJsonQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange<_PrivateAdvancedJsonDocumentSnapshot> + _decodeDocumentChange( + DocumentChange docChange, + _PrivateAdvancedJsonDocumentSnapshot Function(DocumentSnapshot doc) + decodeDoc, + ) { + return FirestoreDocumentChange<_PrivateAdvancedJsonDocumentSnapshot>( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot<_PrivateAdvancedJson> snapshot; + + @override + final List<_PrivateAdvancedJsonQueryDocumentSnapshot> docs; + + @override + final List> + docChanges; +} + +class _PrivateAdvancedJsonQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot<_PrivateAdvancedJson> + implements _PrivateAdvancedJsonDocumentSnapshot { + _PrivateAdvancedJsonQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); + + @override + final QueryDocumentSnapshot<_PrivateAdvancedJson> snapshot; + + @override + final _PrivateAdvancedJson data; + + @override + _PrivateAdvancedJsonDocumentReference get reference { + return _PrivateAdvancedJsonDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class EmptyModelCollectionReference + implements + EmptyModelQuery, + FirestoreCollectionReference { + factory EmptyModelCollectionReference([FirebaseFirestore? firestore]) = + _$EmptyModelCollectionReference; + + static EmptyModel fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return EmptyModel.fromJson(snapshot.data()!); + } + + static Map toFirestore( + EmptyModel value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + EmptyModelDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(EmptyModel value); +} + +class _$EmptyModelCollectionReference extends _$EmptyModelQuery + implements EmptyModelCollectionReference { + factory _$EmptyModelCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$EmptyModelCollectionReference._( + firestore + .collection('firestore-example-app/test/config') + .withConverter( + fromFirestore: EmptyModelCollectionReference.fromFirestore, + toFirestore: EmptyModelCollectionReference.toFirestore, + ), + ); + } + + _$EmptyModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + EmptyModelDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return EmptyModelDocumentReference(reference.doc(id)); + } + + @override + Future add(EmptyModel value) { + return reference.add(value).then((ref) => EmptyModelDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$EmptyModelCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class EmptyModelDocumentReference + extends FirestoreDocumentReference { + factory EmptyModelDocumentReference(DocumentReference reference) = + _$EmptyModelDocumentReference; + + DocumentReference get reference; + + /// A reference to the [EmptyModelCollectionReference] containing this document. + EmptyModelCollectionReference get parent { + return _$EmptyModelCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); +} + +class _$EmptyModelDocumentReference + extends FirestoreDocumentReference + implements EmptyModelDocumentReference { + _$EmptyModelDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [EmptyModelCollectionReference] containing this document. + EmptyModelCollectionReference get parent { + return _$EmptyModelCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(EmptyModelDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(EmptyModelDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(EmptyModelDocumentSnapshot._); + } + + @override + bool operator ==(Object other) { + return other is EmptyModelDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class EmptyModelQuery + implements QueryReference { + @override + EmptyModelQuery limit(int limit); + + @override + EmptyModelQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + EmptyModelQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + EmptyModelQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + EmptyModelQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + EmptyModelDocumentSnapshot? startAtDocument, + EmptyModelDocumentSnapshot? endAtDocument, + EmptyModelDocumentSnapshot? endBeforeDocument, + EmptyModelDocumentSnapshot? startAfterDocument, + }); + + EmptyModelQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + EmptyModelDocumentSnapshot? startAtDocument, + EmptyModelDocumentSnapshot? endAtDocument, + EmptyModelDocumentSnapshot? endBeforeDocument, + EmptyModelDocumentSnapshot? startAfterDocument, + }); +} + +class _$EmptyModelQuery + extends QueryReference + implements EmptyModelQuery { + _$EmptyModelQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + EmptyModelQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(EmptyModelQuerySnapshot._fromQuerySnapshot); + } + + @override + EmptyModelQuery limit(int limit) { + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + EmptyModelQuery limitToLast(int limit) { + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + EmptyModelQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EmptyModelQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EmptyModelQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EmptyModelDocumentSnapshot? startAtDocument, + EmptyModelDocumentSnapshot? endAtDocument, + EmptyModelDocumentSnapshot? endBeforeDocument, + EmptyModelDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + EmptyModelQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EmptyModelDocumentSnapshot? startAtDocument, + EmptyModelDocumentSnapshot? endAtDocument, + EmptyModelDocumentSnapshot? endBeforeDocument, + EmptyModelDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$EmptyModelQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { + EmptyModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + EmptyModelDocumentReference get reference { + return EmptyModelDocumentReference(snapshot.reference); + } + + @override + final EmptyModel? data; +} + +class EmptyModelQuerySnapshot + extends + FirestoreQuerySnapshot { + EmptyModelQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory EmptyModelQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(EmptyModelQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, EmptyModelDocumentSnapshot._); + }).toList(); + + return EmptyModelQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class EmptyModelQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements EmptyModelDocumentSnapshot { + EmptyModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final EmptyModel data; + + @override + EmptyModelDocumentReference get reference { + return EmptyModelDocumentReference(snapshot.reference); + } +} diff --git a/packages/cloud_firestore_odm/example/lib/integration.g.dart b/packages/cloud_firestore_odm/example/lib/integration.g.dart index 0ea7bee..5f81aea 100644 --- a/packages/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration.g.dart @@ -1,2898 +1,8 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint, type=warning - -part of 'integration.dart'; - -// ************************************************************************** -// CollectionGenerator -// ************************************************************************** - -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore // ignore_for_file: type=lint -// ignore_for_file: invalid_use_of_internal_member - -class _Sentinel { - const _Sentinel(); -} - -const _sentinel = _Sentinel(); - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class AdvancedJsonCollectionReference - implements - AdvancedJsonQuery, - FirestoreCollectionReference { - factory AdvancedJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$AdvancedJsonCollectionReference; - - static AdvancedJson fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$AdvancedJsonFromJson(snapshot.data()!); - } - - static Map toFirestore( - AdvancedJson value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - AdvancedJsonDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(AdvancedJson value); -} - -class _$AdvancedJsonCollectionReference extends _$AdvancedJsonQuery - implements AdvancedJsonCollectionReference { - factory _$AdvancedJsonCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$AdvancedJsonCollectionReference._( - firestore.collection('firestore-example-app/test/advanced').withConverter( - fromFirestore: AdvancedJsonCollectionReference.fromFirestore, - toFirestore: AdvancedJsonCollectionReference.toFirestore, - ), - ); - } - - _$AdvancedJsonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - AdvancedJsonDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return AdvancedJsonDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(AdvancedJson value) { - return reference - .add(value) - .then((ref) => AdvancedJsonDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$AdvancedJsonCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class AdvancedJsonDocumentReference extends FirestoreDocumentReference< - AdvancedJson, AdvancedJsonDocumentSnapshot> { - factory AdvancedJsonDocumentReference( - DocumentReference reference) = - _$AdvancedJsonDocumentReference; - - DocumentReference get reference; - - /// A reference to the [AdvancedJsonCollectionReference] containing this document. - AdvancedJsonCollectionReference get parent { - return _$AdvancedJsonCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - AdvancedJson model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - AdvancedJson model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - AdvancedJson model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String? firstName, - FieldValue firstNameFieldValue, - String? lastName, - FieldValue lastNameFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - String? firstName, - FieldValue firstNameFieldValue, - 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< - AdvancedJson, - AdvancedJsonDocumentSnapshot> implements AdvancedJsonDocumentReference { - _$AdvancedJsonDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [AdvancedJsonCollectionReference] containing this document. - AdvancedJsonCollectionReference get parent { - return _$AdvancedJsonCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(AdvancedJsonDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(AdvancedJsonDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(AdvancedJsonDocumentSnapshot._); - } - - Future set( - AdvancedJson model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) async { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - AdvancedJson model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - AdvancedJson model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? firstName = _sentinel, - FieldValue? firstNameFieldValue, - Object? lastName = _sentinel, - FieldValue? lastNameFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class AdvancedJsonQuery - implements QueryReference { - @override - AdvancedJsonQuery limit(int limit); - - @override - AdvancedJsonQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - AdvancedJsonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - AdvancedJsonQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - AdvancedJsonQuery whereFirstName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - AdvancedJsonQuery whereLastName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - AdvancedJsonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }); - - AdvancedJsonQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }); - - AdvancedJsonQuery orderByFirstName({ - bool descending = false, - String? startAt, - String? startAfter, - String? endAt, - String? endBefore, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }); - - AdvancedJsonQuery orderByLastName({ - bool descending = false, - String? startAt, - String? startAfter, - String? endAt, - String? endBefore, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }); -} - -class _$AdvancedJsonQuery - extends QueryReference - implements AdvancedJsonQuery { - _$AdvancedJsonQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(AdvancedJsonQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(AdvancedJsonQuerySnapshot._fromQuerySnapshot); - } - - @override - AdvancedJsonQuery limit(int limit) { - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - AdvancedJsonQuery limitToLast(int limit) { - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - AdvancedJsonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - AdvancedJsonQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - AdvancedJsonQuery whereFirstName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$AdvancedJsonFieldMap['firstName']!, - isEqualTo: isEqualTo != _sentinel - ? _$AdvancedJsonPerFieldToJson.firstName(isEqualTo as String?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$AdvancedJsonPerFieldToJson.firstName(isNotEqualTo as String?) - : null, - isLessThan: isLessThan != null - ? _$AdvancedJsonPerFieldToJson.firstName(isLessThan as String?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .firstName(isLessThanOrEqualTo as String?) - : null, - isGreaterThan: isGreaterThan != null - ? _$AdvancedJsonPerFieldToJson.firstName(isGreaterThan as String?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String?) - : null, - whereIn: whereIn?.map((e) => _$AdvancedJsonPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$AdvancedJsonPerFieldToJson.firstName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - AdvancedJsonQuery whereLastName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$AdvancedJsonFieldMap['lastName']!, - isEqualTo: isEqualTo != _sentinel - ? _$AdvancedJsonPerFieldToJson.lastName(isEqualTo as String?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$AdvancedJsonPerFieldToJson.lastName(isNotEqualTo as String?) - : null, - isLessThan: isLessThan != null - ? _$AdvancedJsonPerFieldToJson.lastName(isLessThan as String?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .lastName(isLessThanOrEqualTo as String?) - : null, - isGreaterThan: isGreaterThan != null - ? _$AdvancedJsonPerFieldToJson.lastName(isGreaterThan as String?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String?) - : null, - whereIn: whereIn?.map((e) => _$AdvancedJsonPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$AdvancedJsonPerFieldToJson.lastName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - AdvancedJsonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - AdvancedJsonQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - AdvancedJsonQuery orderByFirstName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$AdvancedJsonFieldMap['firstName']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - AdvancedJsonQuery orderByLastName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - AdvancedJsonDocumentSnapshot? startAtDocument, - AdvancedJsonDocumentSnapshot? endAtDocument, - AdvancedJsonDocumentSnapshot? endBeforeDocument, - AdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$AdvancedJsonFieldMap['lastName']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$AdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$AdvancedJsonQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class AdvancedJsonDocumentSnapshot - extends FirestoreDocumentSnapshot { - AdvancedJsonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - AdvancedJsonDocumentReference get reference { - return AdvancedJsonDocumentReference( - snapshot.reference, - ); - } - - @override - final AdvancedJson? data; -} - -class AdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot { - AdvancedJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory AdvancedJsonQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(AdvancedJsonQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - AdvancedJsonDocumentSnapshot._, - ); - }).toList(); - - return AdvancedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - AdvancedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class AdvancedJsonQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements AdvancedJsonDocumentSnapshot { - AdvancedJsonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final AdvancedJson data; - - @override - AdvancedJsonDocumentReference get reference { - return AdvancedJsonDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class _PrivateAdvancedJsonCollectionReference - implements - _PrivateAdvancedJsonQuery, - FirestoreCollectionReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> { - factory _PrivateAdvancedJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$_PrivateAdvancedJsonCollectionReference; - - static _PrivateAdvancedJson fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$PrivateAdvancedJsonFromJson(snapshot.data()!); - } - - static Map toFirestore( - _PrivateAdvancedJson value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference<_PrivateAdvancedJson> get reference; - - @override - _PrivateAdvancedJsonDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future<_PrivateAdvancedJsonDocumentReference> add(_PrivateAdvancedJson value); -} - -class _$_PrivateAdvancedJsonCollectionReference - extends _$_PrivateAdvancedJsonQuery - implements _PrivateAdvancedJsonCollectionReference { - factory _$_PrivateAdvancedJsonCollectionReference( - [FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$_PrivateAdvancedJsonCollectionReference._( - firestore - .collection('firestore-example-app/test/private-advanced') - .withConverter( - fromFirestore: - _PrivateAdvancedJsonCollectionReference.fromFirestore, - toFirestore: _PrivateAdvancedJsonCollectionReference.toFirestore, - ), - ); - } - - _$_PrivateAdvancedJsonCollectionReference._( - CollectionReference<_PrivateAdvancedJson> reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference<_PrivateAdvancedJson> get reference => - super.reference as CollectionReference<_PrivateAdvancedJson>; - - @override - _PrivateAdvancedJsonDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return _PrivateAdvancedJsonDocumentReference( - reference.doc(id), - ); - } - - @override - Future<_PrivateAdvancedJsonDocumentReference> add( - _PrivateAdvancedJson value) { - return reference - .add(value) - .then((ref) => _PrivateAdvancedJsonDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$_PrivateAdvancedJsonCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class _PrivateAdvancedJsonDocumentReference - extends FirestoreDocumentReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonDocumentSnapshot> { - factory _PrivateAdvancedJsonDocumentReference( - DocumentReference<_PrivateAdvancedJson> reference) = - _$_PrivateAdvancedJsonDocumentReference; - - DocumentReference<_PrivateAdvancedJson> get reference; - - /// A reference to the [_PrivateAdvancedJsonCollectionReference] containing this document. - _PrivateAdvancedJsonCollectionReference get parent { - return _$_PrivateAdvancedJsonCollectionReference(reference.firestore); - } - - @override - Stream<_PrivateAdvancedJsonDocumentSnapshot> snapshots(); - - @override - Future<_PrivateAdvancedJsonDocumentSnapshot> get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - _PrivateAdvancedJson model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - _PrivateAdvancedJson model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - _PrivateAdvancedJson model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String? firstName, - FieldValue firstNameFieldValue, - String? lastName, - FieldValue lastNameFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - String? firstName, - FieldValue firstNameFieldValue, - 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 - extends FirestoreDocumentReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonDocumentSnapshot> - implements _PrivateAdvancedJsonDocumentReference { - _$_PrivateAdvancedJsonDocumentReference(this.reference); - - @override - final DocumentReference<_PrivateAdvancedJson> reference; - - /// A reference to the [_PrivateAdvancedJsonCollectionReference] containing this document. - _PrivateAdvancedJsonCollectionReference get parent { - return _$_PrivateAdvancedJsonCollectionReference(reference.firestore); - } - - @override - Stream<_PrivateAdvancedJsonDocumentSnapshot> snapshots() { - return reference.snapshots().map(_PrivateAdvancedJsonDocumentSnapshot._); - } - - @override - Future<_PrivateAdvancedJsonDocumentSnapshot> get([GetOptions? options]) { - return reference.get(options).then(_PrivateAdvancedJsonDocumentSnapshot._); - } - - @override - Future<_PrivateAdvancedJsonDocumentSnapshot> transactionGet( - Transaction transaction) { - return transaction - .get(reference) - .then(_PrivateAdvancedJsonDocumentSnapshot._); - } - - Future set( - _PrivateAdvancedJson model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) async { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - _PrivateAdvancedJson model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - _PrivateAdvancedJson model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? firstName = _sentinel, - FieldValue? firstNameFieldValue, - Object? lastName = _sentinel, - FieldValue? lastNameFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class _PrivateAdvancedJsonQuery - implements - QueryReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> { - @override - _PrivateAdvancedJsonQuery limit(int limit); - - @override - _PrivateAdvancedJsonQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - _PrivateAdvancedJsonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - _PrivateAdvancedJsonQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - _PrivateAdvancedJsonQuery whereFirstName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - _PrivateAdvancedJsonQuery whereLastName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - _PrivateAdvancedJsonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }); - - _PrivateAdvancedJsonQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }); - - _PrivateAdvancedJsonQuery orderByFirstName({ - bool descending = false, - String? startAt, - String? startAfter, - String? endAt, - String? endBefore, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }); - - _PrivateAdvancedJsonQuery orderByLastName({ - bool descending = false, - String? startAt, - String? startAfter, - String? endAt, - String? endBefore, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }); -} - -class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> implements _PrivateAdvancedJsonQuery { - _$_PrivateAdvancedJsonQuery( - this._collection, { - required Query<_PrivateAdvancedJson> $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream<_PrivateAdvancedJsonQuerySnapshot> snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(_PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot); - } - - @override - Future<_PrivateAdvancedJsonQuerySnapshot> get([GetOptions? options]) { - return reference - .get(options) - .then(_PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot); - } - - @override - _PrivateAdvancedJsonQuery limit(int limit) { - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery limitToLast(int limit) { - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery whereFirstName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$PrivateAdvancedJsonFieldMap['firstName']!, - isEqualTo: isEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isEqualTo as String?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isNotEqualTo as String?) - : null, - isLessThan: isLessThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isLessThan as String?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isLessThanOrEqualTo as String?) - : null, - isGreaterThan: isGreaterThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isGreaterThan as String?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String?) - : null, - whereIn: whereIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e)), - whereNotIn: whereNotIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery whereLastName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$PrivateAdvancedJsonFieldMap['lastName']!, - isEqualTo: isEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson.lastName(isEqualTo as String?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isNotEqualTo as String?) - : null, - isLessThan: isLessThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isLessThan as String?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isLessThanOrEqualTo as String?) - : null, - isGreaterThan: isGreaterThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isGreaterThan as String?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String?) - : null, - whereIn: whereIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e)), - whereNotIn: whereNotIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery orderByFirstName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy( - _$PrivateAdvancedJsonFieldMap['firstName']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - _PrivateAdvancedJsonQuery orderByLastName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - _PrivateAdvancedJsonDocumentSnapshot? startAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endAtDocument, - _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, - _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy( - _$PrivateAdvancedJsonFieldMap['lastName']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$_PrivateAdvancedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$_PrivateAdvancedJsonQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class _PrivateAdvancedJsonDocumentSnapshot - extends FirestoreDocumentSnapshot<_PrivateAdvancedJson> { - _PrivateAdvancedJsonDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); - - @override - final DocumentSnapshot<_PrivateAdvancedJson> snapshot; - - @override - _PrivateAdvancedJsonDocumentReference get reference { - return _PrivateAdvancedJsonDocumentReference( - snapshot.reference, - ); - } - - @override - final _PrivateAdvancedJson? data; -} - -class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< - _PrivateAdvancedJson, _PrivateAdvancedJsonQueryDocumentSnapshot> { - _PrivateAdvancedJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory _PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot( - QuerySnapshot<_PrivateAdvancedJson> snapshot, - ) { - final docs = - snapshot.docs.map(_PrivateAdvancedJsonQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - _PrivateAdvancedJsonDocumentSnapshot._, - ); - }).toList(); - - return _PrivateAdvancedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange<_PrivateAdvancedJsonDocumentSnapshot> - _decodeDocumentChange( - DocumentChange docChange, - _PrivateAdvancedJsonDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, - ) { - return FirestoreDocumentChange<_PrivateAdvancedJsonDocumentSnapshot>( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot<_PrivateAdvancedJson> snapshot; - - @override - final List<_PrivateAdvancedJsonQueryDocumentSnapshot> docs; - - @override - final List> - docChanges; -} - -class _PrivateAdvancedJsonQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot<_PrivateAdvancedJson> - implements _PrivateAdvancedJsonDocumentSnapshot { - _PrivateAdvancedJsonQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); - - @override - final QueryDocumentSnapshot<_PrivateAdvancedJson> snapshot; - - @override - final _PrivateAdvancedJson data; - - @override - _PrivateAdvancedJsonDocumentReference get reference { - return _PrivateAdvancedJsonDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class EmptyModelCollectionReference - implements - EmptyModelQuery, - FirestoreCollectionReference { - factory EmptyModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EmptyModelCollectionReference; - - static EmptyModel fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return EmptyModel.fromJson(snapshot.data()!); - } - static Map toFirestore( - EmptyModel value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - EmptyModelDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(EmptyModel value); -} - -class _$EmptyModelCollectionReference extends _$EmptyModelQuery - implements EmptyModelCollectionReference { - factory _$EmptyModelCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$EmptyModelCollectionReference._( - firestore.collection('firestore-example-app/test/config').withConverter( - fromFirestore: EmptyModelCollectionReference.fromFirestore, - toFirestore: EmptyModelCollectionReference.toFirestore, - ), - ); - } - - _$EmptyModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - EmptyModelDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return EmptyModelDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(EmptyModel value) { - return reference.add(value).then((ref) => EmptyModelDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$EmptyModelCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class EmptyModelDocumentReference - extends FirestoreDocumentReference { - factory EmptyModelDocumentReference(DocumentReference reference) = - _$EmptyModelDocumentReference; - - DocumentReference get reference; - - /// A reference to the [EmptyModelCollectionReference] containing this document. - EmptyModelCollectionReference get parent { - return _$EmptyModelCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); -} - -class _$EmptyModelDocumentReference - extends FirestoreDocumentReference - implements EmptyModelDocumentReference { - _$EmptyModelDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [EmptyModelCollectionReference] containing this document. - EmptyModelCollectionReference get parent { - return _$EmptyModelCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(EmptyModelDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(EmptyModelDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(EmptyModelDocumentSnapshot._); - } - - @override - bool operator ==(Object other) { - return other is EmptyModelDocumentReference && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class EmptyModelQuery - implements QueryReference { - @override - EmptyModelQuery limit(int limit); - - @override - EmptyModelQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - EmptyModelQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - EmptyModelQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - EmptyModelQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - EmptyModelDocumentSnapshot? startAtDocument, - EmptyModelDocumentSnapshot? endAtDocument, - EmptyModelDocumentSnapshot? endBeforeDocument, - EmptyModelDocumentSnapshot? startAfterDocument, - }); - - EmptyModelQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - EmptyModelDocumentSnapshot? startAtDocument, - EmptyModelDocumentSnapshot? endAtDocument, - EmptyModelDocumentSnapshot? endBeforeDocument, - EmptyModelDocumentSnapshot? startAfterDocument, - }); -} - -class _$EmptyModelQuery - extends QueryReference - implements EmptyModelQuery { - _$EmptyModelQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(EmptyModelQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(EmptyModelQuerySnapshot._fromQuerySnapshot); - } - - @override - EmptyModelQuery limit(int limit) { - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - EmptyModelQuery limitToLast(int limit) { - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - EmptyModelQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EmptyModelQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EmptyModelQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EmptyModelDocumentSnapshot? startAtDocument, - EmptyModelDocumentSnapshot? endAtDocument, - EmptyModelDocumentSnapshot? endBeforeDocument, - EmptyModelDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - EmptyModelQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EmptyModelDocumentSnapshot? startAtDocument, - EmptyModelDocumentSnapshot? endAtDocument, - EmptyModelDocumentSnapshot? endBeforeDocument, - EmptyModelDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$EmptyModelQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { - EmptyModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference( - snapshot.reference, - ); - } - - @override - final EmptyModel? data; -} - -class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot { - EmptyModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory EmptyModelQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(EmptyModelQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - EmptyModelDocumentSnapshot._, - ); - }).toList(); - - return EmptyModelQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class EmptyModelQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements EmptyModelDocumentSnapshot { - EmptyModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final EmptyModel data; - - @override - EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference(snapshot.reference); - } -} +part of 'integration.dart'; // ************************************************************************** // JsonSerializableGenerator @@ -2909,9 +19,9 @@ Map _$EmptyModelToJson(EmptyModel instance) => {}; AdvancedJson _$AdvancedJsonFromJson(Map json) => AdvancedJson( - firstName: json['first_name'] as String?, - lastName: json['LAST_NAME'] as String?, - ); + firstName: json['first_name'] as String?, + lastName: json['LAST_NAME'] as String?, +); const _$AdvancedJsonFieldMap = { 'firstName': 'first_name', @@ -2952,8 +62,8 @@ abstract class _$PrivateAdvancedJsonPerFieldToJson { } Map _$PrivateAdvancedJsonToJson( - _PrivateAdvancedJson instance) => - { - 'first_name': instance.firstName, - 'LAST_NAME': instance.lastName, - }; + _PrivateAdvancedJson instance, +) => { + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; diff --git a/packages/cloud_firestore_odm/example/lib/integration/enums.dart b/packages/cloud_firestore_odm/example/lib/integration/enums.dart index f45aaa5..3f77b82 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/enums.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/enums.dart @@ -6,13 +6,10 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:json_annotation/json_annotation.dart'; +part 'enums.firebase.dart'; part 'enums.g.dart'; -enum TestEnum { - one, - two, - three; -} +enum TestEnum { one, two, three } @JsonSerializable() class Enums { diff --git a/packages/cloud_firestore_odm/example/lib/integration/enums.firebase.dart b/packages/cloud_firestore_odm/example/lib/integration/enums.firebase.dart new file mode 100644 index 0000000..96a030e --- /dev/null +++ b/packages/cloud_firestore_odm/example/lib/integration/enums.firebase.dart @@ -0,0 +1,1848 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'enums.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class EnumsCollectionReference + implements + EnumsQuery, + FirestoreCollectionReference { + factory EnumsCollectionReference([FirebaseFirestore? firestore]) = + _$EnumsCollectionReference; + + static Enums fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return Enums.fromJson(snapshot.data()!); + } + + static Map toFirestore(Enums value, SetOptions? options) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + EnumsDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Enums value); +} + +class _$EnumsCollectionReference extends _$EnumsQuery + implements EnumsCollectionReference { + factory _$EnumsCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$EnumsCollectionReference._( + firestore + .collection('firestore-example-app') + .withConverter( + fromFirestore: EnumsCollectionReference.fromFirestore, + toFirestore: EnumsCollectionReference.toFirestore, + ), + ); + } + + _$EnumsCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + EnumsDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return EnumsDocumentReference(reference.doc(id)); + } + + @override + Future add(Enums value) { + return reference.add(value).then((ref) => EnumsDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$EnumsCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class EnumsDocumentReference + extends FirestoreDocumentReference { + factory EnumsDocumentReference(DocumentReference reference) = + _$EnumsDocumentReference; + + DocumentReference get reference; + + /// A reference to the [EnumsCollectionReference] containing this document. + EnumsCollectionReference get parent { + return _$EnumsCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Enums model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue enumValueFieldValue, + FieldValue nullableEnumValueFieldValue, + FieldValue enumListFieldValue, + FieldValue nullableEnumListFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Enums model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue enumValueFieldValue, + FieldValue nullableEnumValueFieldValue, + FieldValue enumListFieldValue, + FieldValue nullableEnumListFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Enums model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue enumValueFieldValue, + FieldValue nullableEnumValueFieldValue, + FieldValue enumListFieldValue, + FieldValue nullableEnumListFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String id, + FieldValue idFieldValue, + TestEnum enumValue, + FieldValue enumValueFieldValue, + TestEnum? nullableEnumValue, + FieldValue nullableEnumValueFieldValue, + List enumList, + FieldValue enumListFieldValue, + List? nullableEnumList, + FieldValue nullableEnumListFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String id, + FieldValue idFieldValue, + TestEnum enumValue, + FieldValue enumValueFieldValue, + TestEnum? nullableEnumValue, + FieldValue nullableEnumValueFieldValue, + List enumList, + FieldValue enumListFieldValue, + 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 + extends FirestoreDocumentReference + implements EnumsDocumentReference { + _$EnumsDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [EnumsCollectionReference] containing this document. + EnumsCollectionReference get parent { + return _$EnumsCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(EnumsDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(EnumsDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(EnumsDocumentSnapshot._); + } + + Future set( + Enums model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? enumValueFieldValue, + FieldValue? nullableEnumValueFieldValue, + FieldValue? enumListFieldValue, + FieldValue? nullableEnumListFieldValue, + }) async { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + + if (enumValueFieldValue != null) + _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + + if (nullableEnumValueFieldValue != null) + _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + + if (enumListFieldValue != null) + _$EnumsFieldMap['enumList']!: enumListFieldValue, + + if (nullableEnumListFieldValue != null) + _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Enums model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? enumValueFieldValue, + FieldValue? nullableEnumValueFieldValue, + FieldValue? enumListFieldValue, + FieldValue? nullableEnumListFieldValue, + }) { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + + if (enumValueFieldValue != null) + _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + + if (nullableEnumValueFieldValue != null) + _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + + if (enumListFieldValue != null) + _$EnumsFieldMap['enumList']!: enumListFieldValue, + + if (nullableEnumListFieldValue != null) + _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Enums model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? enumValueFieldValue, + FieldValue? nullableEnumValueFieldValue, + FieldValue? enumListFieldValue, + FieldValue? nullableEnumListFieldValue, + }) { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, + + if (enumValueFieldValue != null) + _$EnumsFieldMap['enumValue']!: enumValueFieldValue, + + if (nullableEnumValueFieldValue != null) + _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + + if (enumListFieldValue != null) + _$EnumsFieldMap['enumList']!: enumListFieldValue, + + if (nullableEnumListFieldValue != null) + _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + 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, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class EnumsQuery implements QueryReference { + @override + EnumsQuery limit(int limit); + + @override + EnumsQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + EnumsQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + EnumsQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + EnumsQuery whereId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + EnumsQuery whereEnumValue({ + TestEnum? isEqualTo, + TestEnum? isNotEqualTo, + TestEnum? isLessThan, + TestEnum? isLessThanOrEqualTo, + TestEnum? isGreaterThan, + TestEnum? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + EnumsQuery whereNullableEnumValue({ + TestEnum? isEqualTo, + TestEnum? isNotEqualTo, + TestEnum? isLessThan, + TestEnum? isLessThanOrEqualTo, + TestEnum? isGreaterThan, + TestEnum? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + EnumsQuery whereEnumList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + TestEnum? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + EnumsQuery whereNullableEnumList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + TestEnum? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + EnumsQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }); + + EnumsQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }); + + EnumsQuery orderById({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }); + + EnumsQuery orderByEnumValue({ + bool descending = false, + TestEnum startAt, + TestEnum startAfter, + TestEnum endAt, + TestEnum endBefore, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }); + + EnumsQuery orderByNullableEnumValue({ + bool descending = false, + TestEnum? startAt, + TestEnum? startAfter, + TestEnum? endAt, + TestEnum? endBefore, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }); + + EnumsQuery orderByEnumList({ + bool descending = false, + List startAt, + List startAfter, + List endAt, + List endBefore, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }); + + EnumsQuery orderByNullableEnumList({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }); +} + +class _$EnumsQuery extends QueryReference + implements EnumsQuery { + _$EnumsQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(EnumsQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(EnumsQuerySnapshot._fromQuerySnapshot); + } + + @override + EnumsQuery limit(int limit) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery limitToLast(int limit) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery whereId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$EnumsFieldMap['id']!, + isEqualTo: isEqualTo != _sentinel + ? _$EnumsPerFieldToJson.id(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$EnumsPerFieldToJson.id(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$EnumsPerFieldToJson.id(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$EnumsPerFieldToJson.id(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$EnumsPerFieldToJson.id(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$EnumsPerFieldToJson.id(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$EnumsPerFieldToJson.id(e)), + whereNotIn: whereNotIn?.map((e) => _$EnumsPerFieldToJson.id(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery whereEnumValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$EnumsFieldMap['enumValue']!, + isEqualTo: isEqualTo != _sentinel + ? _$EnumsPerFieldToJson.enumValue(isEqualTo as TestEnum) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$EnumsPerFieldToJson.enumValue(isNotEqualTo as TestEnum) + : null, + isLessThan: isLessThan != null + ? _$EnumsPerFieldToJson.enumValue(isLessThan as TestEnum) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$EnumsPerFieldToJson.enumValue(isLessThanOrEqualTo as TestEnum) + : null, + isGreaterThan: isGreaterThan != null + ? _$EnumsPerFieldToJson.enumValue(isGreaterThan as TestEnum) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$EnumsPerFieldToJson.enumValue( + isGreaterThanOrEqualTo as TestEnum, + ) + : null, + whereIn: whereIn?.map((e) => _$EnumsPerFieldToJson.enumValue(e)), + whereNotIn: whereNotIn?.map((e) => _$EnumsPerFieldToJson.enumValue(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery whereNullableEnumValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$EnumsFieldMap['nullableEnumValue']!, + isEqualTo: isEqualTo != _sentinel + ? _$EnumsPerFieldToJson.nullableEnumValue(isEqualTo as TestEnum?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$EnumsPerFieldToJson.nullableEnumValue(isNotEqualTo as TestEnum?) + : null, + isLessThan: isLessThan != null + ? _$EnumsPerFieldToJson.nullableEnumValue(isLessThan as TestEnum?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$EnumsPerFieldToJson.nullableEnumValue( + isLessThanOrEqualTo as TestEnum?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$EnumsPerFieldToJson.nullableEnumValue( + isGreaterThan as TestEnum?, + ) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$EnumsPerFieldToJson.nullableEnumValue( + isGreaterThanOrEqualTo as TestEnum?, + ) + : null, + whereIn: whereIn?.map( + (e) => _$EnumsPerFieldToJson.nullableEnumValue(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$EnumsPerFieldToJson.nullableEnumValue(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery whereEnumList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$EnumsFieldMap['enumList']!, + isEqualTo: isEqualTo != _sentinel + ? _$EnumsPerFieldToJson.enumList(isEqualTo as List) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$EnumsPerFieldToJson.enumList(isNotEqualTo as List) + : null, + isLessThan: isLessThan != null + ? _$EnumsPerFieldToJson.enumList(isLessThan as List) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$EnumsPerFieldToJson.enumList( + isLessThanOrEqualTo as List, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$EnumsPerFieldToJson.enumList(isGreaterThan as List) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$EnumsPerFieldToJson.enumList( + isGreaterThanOrEqualTo as List, + ) + : null, + arrayContains: arrayContains != null + ? (_$EnumsPerFieldToJson.enumList([arrayContains as TestEnum]) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$EnumsPerFieldToJson.enumList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery whereNullableEnumList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$EnumsFieldMap['nullableEnumList']!, + isEqualTo: isEqualTo != _sentinel + ? _$EnumsPerFieldToJson.nullableEnumList( + isEqualTo as List?, + ) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$EnumsPerFieldToJson.nullableEnumList( + isNotEqualTo as List?, + ) + : null, + isLessThan: isLessThan != null + ? _$EnumsPerFieldToJson.nullableEnumList( + isLessThan as List?, + ) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$EnumsPerFieldToJson.nullableEnumList( + isLessThanOrEqualTo as List?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$EnumsPerFieldToJson.nullableEnumList( + isGreaterThan as List?, + ) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$EnumsPerFieldToJson.nullableEnumList( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$EnumsPerFieldToJson.nullableEnumList([ + arrayContains as TestEnum, + ]) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$EnumsPerFieldToJson.nullableEnumList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EnumsQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + EnumsQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + EnumsQuery orderById({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['id']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.id(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.id(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.id(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.id(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + EnumsQuery orderByEnumValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['enumValue']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.enumValue(startAt as TestEnum), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.enumValue(startAfter as TestEnum), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.enumValue(endAt as TestEnum), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.enumValue(endBefore as TestEnum), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + EnumsQuery orderByNullableEnumValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['nullableEnumValue']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.nullableEnumValue(startAt as TestEnum?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.nullableEnumValue(startAfter as TestEnum?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.nullableEnumValue(endAt as TestEnum?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.nullableEnumValue(endBefore as TestEnum?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + EnumsQuery orderByEnumList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['enumList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.enumList(startAt as List), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.enumList(startAfter as List), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.enumList(endAt as List), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.enumList(endBefore as List), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + EnumsQuery orderByNullableEnumList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EnumsDocumentSnapshot? startAtDocument, + EnumsDocumentSnapshot? endAtDocument, + EnumsDocumentSnapshot? endBeforeDocument, + EnumsDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['nullableEnumList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.nullableEnumList(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.nullableEnumList(startAfter as List?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.nullableEnumList(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.nullableEnumList(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EnumsQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$EnumsQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class EnumsDocumentSnapshot extends FirestoreDocumentSnapshot { + EnumsDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + EnumsDocumentReference get reference { + return EnumsDocumentReference(snapshot.reference); + } + + @override + final Enums? data; +} + +class EnumsQuerySnapshot + extends FirestoreQuerySnapshot { + EnumsQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory EnumsQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { + final docs = snapshot.docs.map(EnumsQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, EnumsDocumentSnapshot._); + }).toList(); + + return EnumsQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + EnumsDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class EnumsQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements EnumsDocumentSnapshot { + EnumsQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Enums data; + + @override + EnumsDocumentReference get reference { + return EnumsDocumentReference(snapshot.reference); + } +} 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 6946dff..f5e9869 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart @@ -4,1738 +4,27 @@ part of 'enums.dart'; -// ************************************************************************** -// CollectionGenerator -// ************************************************************************** - -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore -// ignore_for_file: type=lint -// ignore_for_file: invalid_use_of_internal_member - -class _Sentinel { - const _Sentinel(); -} - -const _sentinel = _Sentinel(); - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class EnumsCollectionReference - implements - EnumsQuery, - FirestoreCollectionReference { - factory EnumsCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EnumsCollectionReference; - - static Enums fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return Enums.fromJson(snapshot.data()!); - } - - static Map toFirestore( - Enums value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - EnumsDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Enums value); -} - -class _$EnumsCollectionReference extends _$EnumsQuery - implements EnumsCollectionReference { - factory _$EnumsCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$EnumsCollectionReference._( - firestore.collection('firestore-example-app').withConverter( - fromFirestore: EnumsCollectionReference.fromFirestore, - toFirestore: EnumsCollectionReference.toFirestore, - ), - ); - } - - _$EnumsCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - EnumsDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return EnumsDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Enums value) { - return reference.add(value).then((ref) => EnumsDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$EnumsCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class EnumsDocumentReference - extends FirestoreDocumentReference { - factory EnumsDocumentReference(DocumentReference reference) = - _$EnumsDocumentReference; - - DocumentReference get reference; - - /// A reference to the [EnumsCollectionReference] containing this document. - EnumsCollectionReference get parent { - return _$EnumsCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Enums model, { - SetOptions? options, - FieldValue idFieldValue, - FieldValue enumValueFieldValue, - FieldValue nullableEnumValueFieldValue, - FieldValue enumListFieldValue, - FieldValue nullableEnumListFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Enums model, { - SetOptions? options, - FieldValue idFieldValue, - FieldValue enumValueFieldValue, - FieldValue nullableEnumValueFieldValue, - FieldValue enumListFieldValue, - FieldValue nullableEnumListFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Enums model, { - SetOptions? options, - FieldValue idFieldValue, - FieldValue enumValueFieldValue, - FieldValue nullableEnumValueFieldValue, - FieldValue enumListFieldValue, - FieldValue nullableEnumListFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String id, - FieldValue idFieldValue, - TestEnum enumValue, - FieldValue enumValueFieldValue, - TestEnum? nullableEnumValue, - FieldValue nullableEnumValueFieldValue, - List enumList, - FieldValue enumListFieldValue, - List? nullableEnumList, - FieldValue nullableEnumListFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - String id, - FieldValue idFieldValue, - TestEnum enumValue, - FieldValue enumValueFieldValue, - TestEnum? nullableEnumValue, - FieldValue nullableEnumValueFieldValue, - List enumList, - FieldValue enumListFieldValue, - 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 - extends FirestoreDocumentReference - implements EnumsDocumentReference { - _$EnumsDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [EnumsCollectionReference] containing this document. - EnumsCollectionReference get parent { - return _$EnumsCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(EnumsDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(EnumsDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(EnumsDocumentSnapshot._); - } - - Future set( - Enums model, { - SetOptions? options, - FieldValue? idFieldValue, - FieldValue? enumValueFieldValue, - FieldValue? nullableEnumValueFieldValue, - FieldValue? enumListFieldValue, - FieldValue? nullableEnumListFieldValue, - }) async { - final json = { - ...model.toJson(), - if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, - if (enumValueFieldValue != null) - _$EnumsFieldMap['enumValue']!: enumValueFieldValue, - if (nullableEnumValueFieldValue != null) - _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, - if (enumListFieldValue != null) - _$EnumsFieldMap['enumList']!: enumListFieldValue, - if (nullableEnumListFieldValue != null) - _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Enums model, { - SetOptions? options, - FieldValue? idFieldValue, - FieldValue? enumValueFieldValue, - FieldValue? nullableEnumValueFieldValue, - FieldValue? enumListFieldValue, - FieldValue? nullableEnumListFieldValue, - }) { - final json = { - ...model.toJson(), - if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, - if (enumValueFieldValue != null) - _$EnumsFieldMap['enumValue']!: enumValueFieldValue, - if (nullableEnumValueFieldValue != null) - _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, - if (enumListFieldValue != null) - _$EnumsFieldMap['enumList']!: enumListFieldValue, - if (nullableEnumListFieldValue != null) - _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Enums model, { - SetOptions? options, - FieldValue? idFieldValue, - FieldValue? enumValueFieldValue, - FieldValue? nullableEnumValueFieldValue, - FieldValue? enumListFieldValue, - FieldValue? nullableEnumListFieldValue, - }) { - final json = { - ...model.toJson(), - if (idFieldValue != null) _$EnumsFieldMap['id']!: idFieldValue, - if (enumValueFieldValue != null) - _$EnumsFieldMap['enumValue']!: enumValueFieldValue, - if (nullableEnumValueFieldValue != null) - _$EnumsFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, - if (enumListFieldValue != null) - _$EnumsFieldMap['enumList']!: enumListFieldValue, - if (nullableEnumListFieldValue != null) - _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - 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, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class EnumsQuery implements QueryReference { - @override - EnumsQuery limit(int limit); - - @override - EnumsQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - EnumsQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - EnumsQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - EnumsQuery whereId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - EnumsQuery whereEnumValue({ - TestEnum? isEqualTo, - TestEnum? isNotEqualTo, - TestEnum? isLessThan, - TestEnum? isLessThanOrEqualTo, - TestEnum? isGreaterThan, - TestEnum? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - EnumsQuery whereNullableEnumValue({ - TestEnum? isEqualTo, - TestEnum? isNotEqualTo, - TestEnum? isLessThan, - TestEnum? isLessThanOrEqualTo, - TestEnum? isGreaterThan, - TestEnum? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - EnumsQuery whereEnumList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - TestEnum? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - EnumsQuery whereNullableEnumList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - TestEnum? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - EnumsQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }); - - EnumsQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }); - - EnumsQuery orderById({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }); - - EnumsQuery orderByEnumValue({ - bool descending = false, - TestEnum startAt, - TestEnum startAfter, - TestEnum endAt, - TestEnum endBefore, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }); - - EnumsQuery orderByNullableEnumValue({ - bool descending = false, - TestEnum? startAt, - TestEnum? startAfter, - TestEnum? endAt, - TestEnum? endBefore, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }); - - EnumsQuery orderByEnumList({ - bool descending = false, - List startAt, - List startAfter, - List endAt, - List endBefore, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }); - - EnumsQuery orderByNullableEnumList({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }); -} - -class _$EnumsQuery extends QueryReference - implements EnumsQuery { - _$EnumsQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(EnumsQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(EnumsQuerySnapshot._fromQuerySnapshot); - } - - @override - EnumsQuery limit(int limit) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery limitToLast(int limit) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery whereId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$EnumsFieldMap['id']!, - isEqualTo: isEqualTo != _sentinel - ? _$EnumsPerFieldToJson.id(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$EnumsPerFieldToJson.id(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$EnumsPerFieldToJson.id(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson.id(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson.id(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson.id(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$EnumsPerFieldToJson.id(e)), - whereNotIn: whereNotIn?.map((e) => _$EnumsPerFieldToJson.id(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery whereEnumValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$EnumsFieldMap['enumValue']!, - isEqualTo: isEqualTo != _sentinel - ? _$EnumsPerFieldToJson.enumValue(isEqualTo as TestEnum) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$EnumsPerFieldToJson.enumValue(isNotEqualTo as TestEnum) - : null, - isLessThan: isLessThan != null - ? _$EnumsPerFieldToJson.enumValue(isLessThan as TestEnum) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson.enumValue(isLessThanOrEqualTo as TestEnum) - : null, - isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson.enumValue(isGreaterThan as TestEnum) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumValue(isGreaterThanOrEqualTo as TestEnum) - : null, - whereIn: whereIn?.map((e) => _$EnumsPerFieldToJson.enumValue(e)), - whereNotIn: whereNotIn?.map((e) => _$EnumsPerFieldToJson.enumValue(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery whereNullableEnumValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$EnumsFieldMap['nullableEnumValue']!, - isEqualTo: isEqualTo != _sentinel - ? _$EnumsPerFieldToJson.nullableEnumValue(isEqualTo as TestEnum?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$EnumsPerFieldToJson.nullableEnumValue(isNotEqualTo as TestEnum?) - : null, - isLessThan: isLessThan != null - ? _$EnumsPerFieldToJson.nullableEnumValue(isLessThan as TestEnum?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isLessThanOrEqualTo as TestEnum?) - : null, - isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isGreaterThan as TestEnum?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isGreaterThanOrEqualTo as TestEnum?) - : null, - whereIn: - whereIn?.map((e) => _$EnumsPerFieldToJson.nullableEnumValue(e)), - whereNotIn: - whereNotIn?.map((e) => _$EnumsPerFieldToJson.nullableEnumValue(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery whereEnumList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$EnumsFieldMap['enumList']!, - isEqualTo: isEqualTo != _sentinel - ? _$EnumsPerFieldToJson.enumList(isEqualTo as List) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$EnumsPerFieldToJson.enumList(isNotEqualTo as List) - : null, - isLessThan: isLessThan != null - ? _$EnumsPerFieldToJson.enumList(isLessThan as List) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumList(isLessThanOrEqualTo as List) - : null, - isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson.enumList(isGreaterThan as List) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumList(isGreaterThanOrEqualTo as List) - : null, - arrayContains: arrayContains != null - ? (_$EnumsPerFieldToJson.enumList([arrayContains as TestEnum]) - as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$EnumsPerFieldToJson.enumList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery whereNullableEnumList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$EnumsFieldMap['nullableEnumList']!, - isEqualTo: isEqualTo != _sentinel - ? _$EnumsPerFieldToJson - .nullableEnumList(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$EnumsPerFieldToJson - .nullableEnumList(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$EnumsPerFieldToJson - .nullableEnumList([arrayContains as TestEnum]) as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$EnumsPerFieldToJson.nullableEnumList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EnumsQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - EnumsQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - EnumsQuery orderById({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['id']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - EnumsQuery orderByEnumValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['enumValue']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - EnumsQuery orderByNullableEnumValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$EnumsFieldMap['nullableEnumValue']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - EnumsQuery orderByEnumList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['enumList']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - EnumsQuery orderByNullableEnumList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EnumsDocumentSnapshot? startAtDocument, - EnumsDocumentSnapshot? endAtDocument, - EnumsDocumentSnapshot? endBeforeDocument, - EnumsDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$EnumsFieldMap['nullableEnumList']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EnumsQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$EnumsQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class EnumsDocumentSnapshot extends FirestoreDocumentSnapshot { - EnumsDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - EnumsDocumentReference get reference { - return EnumsDocumentReference( - snapshot.reference, - ); - } - - @override - final Enums? data; -} - -class EnumsQuerySnapshot - extends FirestoreQuerySnapshot { - EnumsQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory EnumsQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(EnumsQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - EnumsDocumentSnapshot._, - ); - }).toList(); - - return EnumsQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - EnumsDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class EnumsQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements EnumsDocumentSnapshot { - EnumsQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Enums data; - - @override - EnumsDocumentReference get reference { - return EnumsDocumentReference(snapshot.reference); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** Enums _$EnumsFromJson(Map json) => Enums( - id: json['id'] as String, - enumValue: $enumDecodeNullable(_$TestEnumEnumMap, json['enumValue']) ?? - TestEnum.one, - nullableEnumValue: - $enumDecodeNullable(_$TestEnumEnumMap, json['nullableEnumValue']), - enumList: (json['enumList'] as List?) - ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) - .toList() ?? - const [], - nullableEnumList: (json['nullableEnumList'] as List?) + id: json['id'] as String, + enumValue: + $enumDecodeNullable(_$TestEnumEnumMap, json['enumValue']) ?? TestEnum.one, + nullableEnumValue: $enumDecodeNullable( + _$TestEnumEnumMap, + json['nullableEnumValue'], + ), + enumList: + (json['enumList'] as List?) ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) - .toList(), - ); + .toList() ?? + const [], + nullableEnumList: (json['nullableEnumList'] as List?) + ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) + .toList(), +); const _$EnumsFieldMap = { 'id': 'id', @@ -1763,13 +52,14 @@ abstract class _$EnumsPerFieldToJson { } Map _$EnumsToJson(Enums instance) => { - 'id': instance.id, - 'enumValue': _$TestEnumEnumMap[instance.enumValue]!, - 'nullableEnumValue': _$TestEnumEnumMap[instance.nullableEnumValue], - 'enumList': instance.enumList.map((e) => _$TestEnumEnumMap[e]!).toList(), - 'nullableEnumList': - instance.nullableEnumList?.map((e) => _$TestEnumEnumMap[e]!).toList(), - }; + 'id': instance.id, + 'enumValue': _$TestEnumEnumMap[instance.enumValue]!, + 'nullableEnumValue': _$TestEnumEnumMap[instance.nullableEnumValue], + 'enumList': instance.enumList.map((e) => _$TestEnumEnumMap[e]!).toList(), + 'nullableEnumList': instance.nullableEnumList + ?.map((e) => _$TestEnumEnumMap[e]!) + .toList(), +}; const _$TestEnumEnumMap = { TestEnum.one: 'one', diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.dart index 4453f8b..6953668 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.dart @@ -8,12 +8,13 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +part 'freezed.firebase.dart'; part 'freezed.freezed.dart'; part 'freezed.g.dart'; @Collection('freezed-test') @freezed -class Person with _$Person { +abstract class Person with _$Person { @JsonSerializable(fieldRename: FieldRename.snake) factory Person({ required String firstName, @@ -28,9 +29,8 @@ final personRef = PersonCollectionReference(); @Collection('freezed-test') @freezed -class PublicRedirected with _$PublicRedirected { +abstract class PublicRedirected with _$PublicRedirected { factory PublicRedirected({required String value}) = PublicRedirected2; - factory PublicRedirected.fromJson(Map json) => - _$PublicRedirectedFromJson(json); + factory PublicRedirected.fromJson(Map json) => _$PublicRedirectedFromJson(json); } diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.firebase.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.firebase.dart new file mode 100644 index 0000000..3fbb2cf --- /dev/null +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.firebase.dart @@ -0,0 +1,2138 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'freezed.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class PersonCollectionReference + implements + PersonQuery, + FirestoreCollectionReference { + factory PersonCollectionReference([FirebaseFirestore? firestore]) = + _$PersonCollectionReference; + + static Person fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return Person.fromJson(snapshot.data()!); + } + + static Map toFirestore(Person value, SetOptions? options) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + PersonDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Person value); +} + +class _$PersonCollectionReference extends _$PersonQuery + implements PersonCollectionReference { + factory _$PersonCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$PersonCollectionReference._( + firestore + .collection('freezed-test') + .withConverter( + fromFirestore: PersonCollectionReference.fromFirestore, + toFirestore: PersonCollectionReference.toFirestore, + ), + ); + } + + _$PersonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + PersonDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return PersonDocumentReference(reference.doc(id)); + } + + @override + Future add(Person value) { + return reference.add(value).then((ref) => PersonDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$PersonCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class PersonDocumentReference + extends FirestoreDocumentReference { + factory PersonDocumentReference(DocumentReference reference) = + _$PersonDocumentReference; + + DocumentReference get reference; + + /// A reference to the [PersonCollectionReference] containing this document. + PersonCollectionReference get parent { + return _$PersonCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Person model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Person model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Person model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String firstName, + FieldValue firstNameFieldValue, + String lastName, + FieldValue lastNameFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String firstName, + FieldValue firstNameFieldValue, + 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 + extends FirestoreDocumentReference + implements PersonDocumentReference { + _$PersonDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [PersonCollectionReference] containing this document. + PersonCollectionReference get parent { + return _$PersonCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(PersonDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(PersonDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(PersonDocumentSnapshot._); + } + + Future set( + Person model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) async { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Person model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Person model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? firstName = _sentinel, + FieldValue? firstNameFieldValue, + Object? lastName = _sentinel, + FieldValue? lastNameFieldValue, + }) async { + 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) + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastName != _sentinel) + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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) + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastName != _sentinel) + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + 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) + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastName != _sentinel) + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is PersonDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class PersonQuery + implements QueryReference { + @override + PersonQuery limit(int limit); + + @override + PersonQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + PersonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PersonQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PersonQuery whereFirstName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PersonQuery whereLastName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + PersonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }); + + PersonQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }); + + PersonQuery orderByFirstName({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }); + + PersonQuery orderByLastName({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }); +} + +class _$PersonQuery extends QueryReference + implements PersonQuery { + _$PersonQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(PersonQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(PersonQuerySnapshot._fromQuerySnapshot); + } + + @override + PersonQuery limit(int limit) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery limitToLast(int limit) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery whereFirstName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PersonFieldMap['firstName']!, + isEqualTo: isEqualTo != _sentinel + ? _$PersonPerFieldToJson.firstName(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PersonPerFieldToJson.firstName(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PersonPerFieldToJson.firstName(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PersonPerFieldToJson.firstName(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$PersonPerFieldToJson.firstName(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PersonPerFieldToJson.firstName(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery whereLastName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PersonFieldMap['lastName']!, + isEqualTo: isEqualTo != _sentinel + ? _$PersonPerFieldToJson.lastName(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PersonPerFieldToJson.lastName(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PersonPerFieldToJson.lastName(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PersonPerFieldToJson.lastName(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$PersonPerFieldToJson.lastName(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PersonPerFieldToJson.lastName(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PersonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PersonQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PersonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PersonQuery orderByFirstName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['firstName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.firstName(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.firstName(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.firstName(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.firstName(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PersonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PersonQuery orderByLastName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['lastName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.lastName(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.lastName(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.lastName(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.lastName(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PersonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$PersonQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { + PersonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + PersonDocumentReference get reference { + return PersonDocumentReference(snapshot.reference); + } + + @override + final Person? data; +} + +class PersonQuerySnapshot + extends FirestoreQuerySnapshot { + PersonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory PersonQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, PersonDocumentSnapshot._); + }).toList(); + + return PersonQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements PersonDocumentSnapshot { + PersonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Person data; + + @override + PersonDocumentReference get reference { + return PersonDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class PublicRedirectedCollectionReference + implements + PublicRedirectedQuery, + FirestoreCollectionReference< + PublicRedirected, + PublicRedirectedQuerySnapshot + > { + factory PublicRedirectedCollectionReference([FirebaseFirestore? firestore]) = + _$PublicRedirectedCollectionReference; + + static PublicRedirected fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return PublicRedirected.fromJson(snapshot.data()!); + } + + static Map toFirestore( + PublicRedirected value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + PublicRedirectedDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(PublicRedirected value); +} + +class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery + implements PublicRedirectedCollectionReference { + factory _$PublicRedirectedCollectionReference([ + FirebaseFirestore? firestore, + ]) { + firestore ??= FirebaseFirestore.instance; + + return _$PublicRedirectedCollectionReference._( + firestore + .collection('freezed-test') + .withConverter( + fromFirestore: PublicRedirectedCollectionReference.fromFirestore, + toFirestore: PublicRedirectedCollectionReference.toFirestore, + ), + ); + } + + _$PublicRedirectedCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + PublicRedirectedDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return PublicRedirectedDocumentReference(reference.doc(id)); + } + + @override + Future add(PublicRedirected value) { + return reference + .add(value) + .then((ref) => PublicRedirectedDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$PublicRedirectedCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class PublicRedirectedDocumentReference + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > { + factory PublicRedirectedDocumentReference( + DocumentReference reference, + ) = _$PublicRedirectedDocumentReference; + + DocumentReference get reference; + + /// A reference to the [PublicRedirectedCollectionReference] containing this document. + PublicRedirectedCollectionReference get parent { + return _$PublicRedirectedCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + PublicRedirected model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + PublicRedirected model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + PublicRedirected model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({String value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > + implements PublicRedirectedDocumentReference { + _$PublicRedirectedDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [PublicRedirectedCollectionReference] containing this document. + PublicRedirectedCollectionReference get parent { + return _$PublicRedirectedCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(PublicRedirectedDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(PublicRedirectedDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); + } + + Future set( + PublicRedirected model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + PublicRedirected model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + PublicRedirected model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + 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) + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is PublicRedirectedDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class PublicRedirectedQuery + implements QueryReference { + @override + PublicRedirectedQuery limit(int limit); + + @override + PublicRedirectedQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + PublicRedirectedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PublicRedirectedQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PublicRedirectedQuery whereValue({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + PublicRedirectedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }); + + PublicRedirectedQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }); + + PublicRedirectedQuery orderByValue({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }); +} + +class _$PublicRedirectedQuery + extends QueryReference + implements PublicRedirectedQuery { + _$PublicRedirectedQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + PublicRedirectedQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(PublicRedirectedQuerySnapshot._fromQuerySnapshot); + } + + @override + PublicRedirectedQuery limit(int limit) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery limitToLast(int limit) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PublicRedirected2FieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$PublicRedirected2PerFieldToJson.value(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PublicRedirected2PerFieldToJson.value(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PublicRedirected2PerFieldToJson.value(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PublicRedirected2PerFieldToJson.value( + isLessThanOrEqualTo as String, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$PublicRedirected2PerFieldToJson.value(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PublicRedirected2PerFieldToJson.value( + isGreaterThanOrEqualTo as String, + ) + : null, + whereIn: whereIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PublicRedirectedQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PublicRedirectedQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PublicRedirected2FieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PublicRedirected2PerFieldToJson.value(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PublicRedirected2PerFieldToJson.value(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PublicRedirected2PerFieldToJson.value(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PublicRedirected2PerFieldToJson.value(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$PublicRedirectedQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class PublicRedirectedDocumentSnapshot + extends FirestoreDocumentSnapshot { + PublicRedirectedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + PublicRedirectedDocumentReference get reference { + return PublicRedirectedDocumentReference(snapshot.reference); + } + + @override + final PublicRedirected? data; +} + +class PublicRedirectedQuerySnapshot + extends + FirestoreQuerySnapshot< + PublicRedirected, + PublicRedirectedQueryDocumentSnapshot + > { + PublicRedirectedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory PublicRedirectedQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(PublicRedirectedQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, PublicRedirectedDocumentSnapshot._); + }).toList(); + + return PublicRedirectedQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) + decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> + docChanges; +} + +class PublicRedirectedQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements PublicRedirectedDocumentSnapshot { + PublicRedirectedQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final PublicRedirected data; + + @override + PublicRedirectedDocumentReference get reference { + return PublicRedirectedDocumentReference(snapshot.reference); + } +} diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart index 5c1d22c..268bc1b 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,357 +9,545 @@ part of 'freezed.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Person _$PersonFromJson(Map json) { - return _Person.fromJson(json); -} - /// @nodoc mixin _$Person { - String get firstName => throw _privateConstructorUsedError; - @JsonKey(name: 'LAST_NAME') - String get lastName => throw _privateConstructorUsedError; - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored => throw _privateConstructorUsedError; + + String get firstName;@JsonKey(name: 'LAST_NAME') String get lastName;@JsonKey(includeFromJson: false, includeToJson: false) int? get ignored; +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PersonCopyWith get copyWith => _$PersonCopyWithImpl(this as Person, _$identity); /// Serializes this Person to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PersonCopyWith get copyWith => throw _privateConstructorUsedError; + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); } -/// @nodoc -abstract class $PersonCopyWith<$Res> { - factory $PersonCopyWith(Person value, $Res Function(Person) then) = - _$PersonCopyWithImpl<$Res, Person>; - @useResult - $Res call( - {String firstName, - @JsonKey(name: 'LAST_NAME') String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) int? ignored}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; +} + + } /// @nodoc -class _$PersonCopyWithImpl<$Res, $Val extends Person> +abstract mixin class $PersonCopyWith<$Res> { + factory $PersonCopyWith(Person value, $Res Function(Person) _then) = _$PersonCopyWithImpl; +@useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); + + + + +} +/// @nodoc +class _$PersonCopyWithImpl<$Res> implements $PersonCopyWith<$Res> { - _$PersonCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? firstName = null, - Object? lastName = null, - Object? ignored = freezed, - }) { - return _then(_value.copyWith( - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - ignored: freezed == ignored - ? _value.ignored - : ignored // ignore: cast_nullable_to_non_nullable - as int?, - ) as $Val); - } + _$PersonCopyWithImpl(this._self, this._then); + + final Person _self; + final $Res Function(Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_self.copyWith( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); } -/// @nodoc -abstract class _$$PersonImplCopyWith<$Res> implements $PersonCopyWith<$Res> { - factory _$$PersonImplCopyWith( - _$PersonImpl value, $Res Function(_$PersonImpl) then) = - __$$PersonImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String firstName, - @JsonKey(name: 'LAST_NAME') String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) int? ignored}); } -/// @nodoc -class __$$PersonImplCopyWithImpl<$Res> - extends _$PersonCopyWithImpl<$Res, _$PersonImpl> - implements _$$PersonImplCopyWith<$Res> { - __$$PersonImplCopyWithImpl( - _$PersonImpl _value, $Res Function(_$PersonImpl) _then) - : super(_value, _then); - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? firstName = null, - Object? lastName = null, - Object? ignored = freezed, - }) { - return _then(_$PersonImpl( - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - ignored: freezed == ignored - ? _value.ignored - : ignored // ignore: cast_nullable_to_non_nullable - as int?, - )); - } + +/// Adds pattern-matching-related methods to [Person]. +extension PersonPatterns on Person { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Person value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Person value) $default,){ +final _that = this; +switch (_that) { +case _Person(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Person value)? $default,){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored) $default,) {final _that = this; +switch (_that) { +case _Person(): +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable(fieldRename: FieldRename.snake) -class _$PersonImpl implements _Person { - _$PersonImpl( - {required this.firstName, - @JsonKey(name: 'LAST_NAME') required this.lastName, - @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); - - factory _$PersonImpl.fromJson(Map json) => - _$$PersonImplFromJson(json); - - @override - final String firstName; - @override - @JsonKey(name: 'LAST_NAME') - final String lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - final int? ignored; - - @override - String toString() { - return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PersonImpl && - (identical(other.firstName, firstName) || - other.firstName == firstName) && - (identical(other.lastName, lastName) || - other.lastName == lastName) && - (identical(other.ignored, ignored) || other.ignored == ignored)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, firstName, lastName, ignored); - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - __$$PersonImplCopyWithImpl<_$PersonImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PersonImplToJson( - this, - ); - } +class _Person implements Person { + _Person({required this.firstName, @JsonKey(name: 'LAST_NAME') required this.lastName, @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); + factory _Person.fromJson(Map json) => _$PersonFromJson(json); + +@override final String firstName; +@override@JsonKey(name: 'LAST_NAME') final String lastName; +@override@JsonKey(includeFromJson: false, includeToJson: false) final int? ignored; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PersonCopyWith<_Person> get copyWith => __$PersonCopyWithImpl<_Person>(this, _$identity); + +@override +Map toJson() { + return _$PersonToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); } -abstract class _Person implements Person { - factory _Person( - {required final String firstName, - @JsonKey(name: 'LAST_NAME') required final String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) - final int? ignored}) = _$PersonImpl; +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; +} + + +} + +/// @nodoc +abstract mixin class _$PersonCopyWith<$Res> implements $PersonCopyWith<$Res> { + factory _$PersonCopyWith(_Person value, $Res Function(_Person) _then) = __$PersonCopyWithImpl; +@override @useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); - factory _Person.fromJson(Map json) = _$PersonImpl.fromJson; - @override - String get firstName; - @override - @JsonKey(name: 'LAST_NAME') - String get lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored; - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - throw _privateConstructorUsedError; + +} +/// @nodoc +class __$PersonCopyWithImpl<$Res> + implements _$PersonCopyWith<$Res> { + __$PersonCopyWithImpl(this._self, this._then); + + final _Person _self; + final $Res Function(_Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_Person( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); } -PublicRedirected _$PublicRedirectedFromJson(Map json) { - return PublicRedirected2.fromJson(json); + +} + +PublicRedirected _$PublicRedirectedFromJson( + Map json +) { + return PublicRedirected2.fromJson( + json + ); } /// @nodoc mixin _$PublicRedirected { - String get value => throw _privateConstructorUsedError; + + String get value; +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirectedCopyWith get copyWith => _$PublicRedirectedCopyWithImpl(this as PublicRedirected, _$identity); /// Serializes this PublicRedirected to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PublicRedirectedCopyWith get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected&&(identical(other.value, value) || other.value == value)); } -/// @nodoc -abstract class $PublicRedirectedCopyWith<$Res> { - factory $PublicRedirectedCopyWith( - PublicRedirected value, $Res Function(PublicRedirected) then) = - _$PublicRedirectedCopyWithImpl<$Res, PublicRedirected>; - @useResult - $Res call({String value}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString() { + return 'PublicRedirected(value: $value)'; } -/// @nodoc -class _$PublicRedirectedCopyWithImpl<$Res, $Val extends PublicRedirected> - implements $PublicRedirectedCopyWith<$Res> { - _$PublicRedirectedCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = null, - }) { - return _then(_value.copyWith( - value: null == value - ? _value.value - : value // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } + } /// @nodoc -abstract class _$$PublicRedirected2ImplCopyWith<$Res> +abstract mixin class $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirectedCopyWith(PublicRedirected value, $Res Function(PublicRedirected) _then) = _$PublicRedirectedCopyWithImpl; +@useResult +$Res call({ + String value +}); + + + + +} +/// @nodoc +class _$PublicRedirectedCopyWithImpl<$Res> implements $PublicRedirectedCopyWith<$Res> { - factory _$$PublicRedirected2ImplCopyWith(_$PublicRedirected2Impl value, - $Res Function(_$PublicRedirected2Impl) then) = - __$$PublicRedirected2ImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String value}); + _$PublicRedirectedCopyWithImpl(this._self, this._then); + + final PublicRedirected _self; + final $Res Function(PublicRedirected) _then; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? value = null,}) { + return _then(_self.copyWith( +value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PublicRedirected]. +extension PublicRedirectedPatterns on PublicRedirected { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( PublicRedirected2 value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( PublicRedirected2 value) $default,){ +final _that = this; +switch (_that) { +case PublicRedirected2(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( PublicRedirected2 value)? $default,){ +final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String value)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that.value);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String value) $default,) {final _that = this; +switch (_that) { +case PublicRedirected2(): +return $default(_that.value);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String value)? $default,) {final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that.value);case _: + return null; + +} } -/// @nodoc -class __$$PublicRedirected2ImplCopyWithImpl<$Res> - extends _$PublicRedirectedCopyWithImpl<$Res, _$PublicRedirected2Impl> - implements _$$PublicRedirected2ImplCopyWith<$Res> { - __$$PublicRedirected2ImplCopyWithImpl(_$PublicRedirected2Impl _value, - $Res Function(_$PublicRedirected2Impl) _then) - : super(_value, _then); - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = null, - }) { - return _then(_$PublicRedirected2Impl( - value: null == value - ? _value.value - : value // ignore: cast_nullable_to_non_nullable - as String, - )); - } } /// @nodoc @JsonSerializable() -class _$PublicRedirected2Impl implements PublicRedirected2 { - _$PublicRedirected2Impl({required this.value}); - - factory _$PublicRedirected2Impl.fromJson(Map json) => - _$$PublicRedirected2ImplFromJson(json); - - @override - final String value; - - @override - String toString() { - return 'PublicRedirected(value: $value)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PublicRedirected2Impl && - (identical(other.value, value) || other.value == value)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, value); - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - __$$PublicRedirected2ImplCopyWithImpl<_$PublicRedirected2Impl>( - this, _$identity); - - @override - Map toJson() { - return _$$PublicRedirected2ImplToJson( - this, - ); - } + +class PublicRedirected2 implements PublicRedirected { + PublicRedirected2({required this.value}); + factory PublicRedirected2.fromJson(Map json) => _$PublicRedirected2FromJson(json); + +@override final String value; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirected2CopyWith get copyWith => _$PublicRedirected2CopyWithImpl(this, _$identity); + +@override +Map toJson() { + return _$PublicRedirected2ToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected2&&(identical(other.value, value) || other.value == value)); } -abstract class PublicRedirected2 implements PublicRedirected { - factory PublicRedirected2({required final String value}) = - _$PublicRedirected2Impl; +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString() { + return 'PublicRedirected(value: $value)'; +} + + +} + +/// @nodoc +abstract mixin class $PublicRedirected2CopyWith<$Res> implements $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirected2CopyWith(PublicRedirected2 value, $Res Function(PublicRedirected2) _then) = _$PublicRedirected2CopyWithImpl; +@override @useResult +$Res call({ + String value +}); - factory PublicRedirected2.fromJson(Map json) = - _$PublicRedirected2Impl.fromJson; - @override - String get value; - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - throw _privateConstructorUsedError; + +} +/// @nodoc +class _$PublicRedirected2CopyWithImpl<$Res> + implements $PublicRedirected2CopyWith<$Res> { + _$PublicRedirected2CopyWithImpl(this._self, this._then); + + final PublicRedirected2 _self; + final $Res Function(PublicRedirected2) _then; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? value = null,}) { + return _then(PublicRedirected2( +value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as String, + )); } + + +} + +// dart format on 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 9f9482d..d813c59 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart @@ -4,2116 +4,43 @@ part of 'freezed.dart'; -// ************************************************************************** -// CollectionGenerator -// ************************************************************************** - -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore -// ignore_for_file: type=lint -// ignore_for_file: invalid_use_of_internal_member - -class _Sentinel { - const _Sentinel(); -} - -const _sentinel = _Sentinel(); - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class PersonCollectionReference - implements - PersonQuery, - FirestoreCollectionReference { - factory PersonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PersonCollectionReference; - - static Person fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return Person.fromJson(snapshot.data()!); - } - - static Map toFirestore( - Person value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - PersonDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Person value); -} - -class _$PersonCollectionReference extends _$PersonQuery - implements PersonCollectionReference { - factory _$PersonCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$PersonCollectionReference._( - firestore.collection('freezed-test').withConverter( - fromFirestore: PersonCollectionReference.fromFirestore, - toFirestore: PersonCollectionReference.toFirestore, - ), - ); - } - - _$PersonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - PersonDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return PersonDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Person value) { - return reference.add(value).then((ref) => PersonDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$PersonCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class PersonDocumentReference - extends FirestoreDocumentReference { - factory PersonDocumentReference(DocumentReference reference) = - _$PersonDocumentReference; - - DocumentReference get reference; - - /// A reference to the [PersonCollectionReference] containing this document. - PersonCollectionReference get parent { - return _$PersonCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Person model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Person model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Person model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String firstName, - FieldValue firstNameFieldValue, - String lastName, - FieldValue lastNameFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - String firstName, - FieldValue firstNameFieldValue, - 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 - extends FirestoreDocumentReference - implements PersonDocumentReference { - _$PersonDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [PersonCollectionReference] containing this document. - PersonCollectionReference get parent { - return _$PersonCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(PersonDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(PersonDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(PersonDocumentSnapshot._); - } - - Future set( - Person model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) async { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Person model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Person model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? firstName = _sentinel, - FieldValue? firstNameFieldValue, - Object? lastName = _sentinel, - FieldValue? lastNameFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class PersonQuery - implements QueryReference { - @override - PersonQuery limit(int limit); - - @override - PersonQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - PersonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PersonQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PersonQuery whereFirstName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PersonQuery whereLastName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - PersonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }); - - PersonQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }); - - PersonQuery orderByFirstName({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }); - - PersonQuery orderByLastName({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }); -} - -class _$PersonQuery extends QueryReference - implements PersonQuery { - _$PersonQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(PersonQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(PersonQuerySnapshot._fromQuerySnapshot); - } - - @override - PersonQuery limit(int limit) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery limitToLast(int limit) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery whereFirstName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['firstName']!, - isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.firstName(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.firstName(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery whereLastName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['lastName']!, - isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.lastName(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.lastName(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PersonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PersonQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PersonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PersonQuery orderByFirstName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['firstName']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PersonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PersonQuery orderByLastName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['lastName']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PersonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$PersonQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { - PersonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - PersonDocumentReference get reference { - return PersonDocumentReference( - snapshot.reference, - ); - } - - @override - final Person? data; -} - -class PersonQuerySnapshot - extends FirestoreQuerySnapshot { - PersonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory PersonQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PersonDocumentSnapshot._, - ); - }).toList(); - - return PersonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements PersonDocumentSnapshot { - PersonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Person data; - - @override - PersonDocumentReference get reference { - return PersonDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class PublicRedirectedCollectionReference - implements - PublicRedirectedQuery, - FirestoreCollectionReference { - factory PublicRedirectedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PublicRedirectedCollectionReference; - - static PublicRedirected fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return PublicRedirected.fromJson(snapshot.data()!); - } - - static Map toFirestore( - PublicRedirected value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - PublicRedirectedDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(PublicRedirected value); -} - -class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery - implements PublicRedirectedCollectionReference { - factory _$PublicRedirectedCollectionReference( - [FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$PublicRedirectedCollectionReference._( - firestore.collection('freezed-test').withConverter( - fromFirestore: PublicRedirectedCollectionReference.fromFirestore, - toFirestore: PublicRedirectedCollectionReference.toFirestore, - ), - ); - } - - _$PublicRedirectedCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - PublicRedirectedDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return PublicRedirectedDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(PublicRedirected value) { - return reference - .add(value) - .then((ref) => PublicRedirectedDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$PublicRedirectedCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class PublicRedirectedDocumentReference - extends FirestoreDocumentReference { - factory PublicRedirectedDocumentReference( - DocumentReference reference) = - _$PublicRedirectedDocumentReference; - - DocumentReference get reference; - - /// A reference to the [PublicRedirectedCollectionReference] containing this document. - PublicRedirectedCollectionReference get parent { - return _$PublicRedirectedCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - PublicRedirected model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - PublicRedirected model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - PublicRedirected model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - PublicRedirected, PublicRedirectedDocumentSnapshot> - implements PublicRedirectedDocumentReference { - _$PublicRedirectedDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [PublicRedirectedCollectionReference] containing this document. - PublicRedirectedCollectionReference get parent { - return _$PublicRedirectedCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(PublicRedirectedDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(PublicRedirectedDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); - } - - Future set( - PublicRedirected model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - PublicRedirected model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - PublicRedirected model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class PublicRedirectedQuery - implements QueryReference { - @override - PublicRedirectedQuery limit(int limit); - - @override - PublicRedirectedQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - PublicRedirectedQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PublicRedirectedQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PublicRedirectedQuery whereValue({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - PublicRedirectedQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }); - - PublicRedirectedQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }); - - PublicRedirectedQuery orderByValue({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }); -} - -class _$PublicRedirectedQuery - extends QueryReference - implements PublicRedirectedQuery { - _$PublicRedirectedQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(PublicRedirectedQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(PublicRedirectedQuerySnapshot._fromQuerySnapshot); - } - - @override - PublicRedirectedQuery limit(int limit) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery limitToLast(int limit) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PublicRedirected2ImplFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson.value(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$$PublicRedirected2ImplPerFieldToJson.value(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - whereNotIn: whereNotIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PublicRedirectedQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PublicRedirectedQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy( - _$$PublicRedirected2ImplFieldMap['value']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$PublicRedirectedQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class PublicRedirectedDocumentSnapshot - extends FirestoreDocumentSnapshot { - PublicRedirectedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference( - snapshot.reference, - ); - } - - @override - final PublicRedirected? data; -} - -class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< - PublicRedirected, PublicRedirectedQueryDocumentSnapshot> { - PublicRedirectedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory PublicRedirectedQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(PublicRedirectedQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PublicRedirectedDocumentSnapshot._, - ); - }).toList(); - - return PublicRedirectedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> - docChanges; -} - -class PublicRedirectedQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements PublicRedirectedDocumentSnapshot { - PublicRedirectedQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final PublicRedirected data; - - @override - PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference(snapshot.reference); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$PersonImpl _$$PersonImplFromJson(Map json) => _$PersonImpl( - firstName: json['first_name'] as String, - lastName: json['LAST_NAME'] as String, - ); +_Person _$PersonFromJson(Map json) => _Person( + firstName: json['first_name'] as String, + lastName: json['LAST_NAME'] as String, +); -const _$$PersonImplFieldMap = { +const _$PersonFieldMap = { 'firstName': 'first_name', 'lastName': 'LAST_NAME', }; // ignore: unused_element -abstract class _$$PersonImplPerFieldToJson { +abstract class _$PersonPerFieldToJson { // ignore: unused_element static Object? firstName(String instance) => instance; // ignore: unused_element static Object? lastName(String instance) => instance; } -Map _$$PersonImplToJson(_$PersonImpl instance) => - { - 'first_name': instance.firstName, - 'LAST_NAME': instance.lastName, - }; +Map _$PersonToJson(_Person instance) => { + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; -_$PublicRedirected2Impl _$$PublicRedirected2ImplFromJson( - Map json) => - _$PublicRedirected2Impl( - value: json['value'] as String, - ); +PublicRedirected2 _$PublicRedirected2FromJson(Map json) => + PublicRedirected2(value: json['value'] as String); -const _$$PublicRedirected2ImplFieldMap = { - 'value': 'value', -}; +const _$PublicRedirected2FieldMap = {'value': 'value'}; // ignore: unused_element -abstract class _$$PublicRedirected2ImplPerFieldToJson { +abstract class _$PublicRedirected2PerFieldToJson { // ignore: unused_element static Object? value(String instance) => instance; } -Map _$$PublicRedirected2ImplToJson( - _$PublicRedirected2Impl instance) => - { - 'value': instance.value, - }; +Map _$PublicRedirected2ToJson(PublicRedirected2 instance) => + {'value': instance.value}; diff --git a/packages/cloud_firestore_odm/example/lib/integration/named_query.dart b/packages/cloud_firestore_odm/example/lib/integration/named_query.dart index 4358dc5..6ac90b9 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/named_query.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/named_query.dart @@ -6,6 +6,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +part 'named_query.firebase.dart'; part 'named_query.g.dart'; @NamedQuery('named-bundle-test-4') diff --git a/packages/cloud_firestore_odm/example/lib/integration/named_query.firebase.dart b/packages/cloud_firestore_odm/example/lib/integration/named_query.firebase.dart new file mode 100644 index 0000000..389c298 --- /dev/null +++ b/packages/cloud_firestore_odm/example/lib/integration/named_query.firebase.dart @@ -0,0 +1,945 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'named_query.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class ConflictCollectionReference + implements + ConflictQuery, + FirestoreCollectionReference { + factory ConflictCollectionReference([FirebaseFirestore? firestore]) = + _$ConflictCollectionReference; + + static Conflict fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$ConflictFromJson(snapshot.data()!); + } + + static Map toFirestore(Conflict value, SetOptions? options) { + return _$ConflictToJson(value); + } + + @override + CollectionReference get reference; + + @override + ConflictDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Conflict value); +} + +class _$ConflictCollectionReference extends _$ConflictQuery + implements ConflictCollectionReference { + factory _$ConflictCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$ConflictCollectionReference._( + firestore + .collection('firestore-example-app/42/named-query-conflict') + .withConverter( + fromFirestore: ConflictCollectionReference.fromFirestore, + toFirestore: ConflictCollectionReference.toFirestore, + ), + ); + } + + _$ConflictCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + ConflictDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return ConflictDocumentReference(reference.doc(id)); + } + + @override + Future add(Conflict value) { + return reference.add(value).then((ref) => ConflictDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$ConflictCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class ConflictDocumentReference + extends FirestoreDocumentReference { + factory ConflictDocumentReference(DocumentReference reference) = + _$ConflictDocumentReference; + + DocumentReference get reference; + + /// A reference to the [ConflictCollectionReference] containing this document. + ConflictCollectionReference get parent { + return _$ConflictCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Conflict model, { + SetOptions? options, + FieldValue numberFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Conflict model, { + SetOptions? options, + FieldValue numberFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Conflict model, { + SetOptions? options, + FieldValue numberFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({num number, FieldValue numberFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + extends FirestoreDocumentReference + implements ConflictDocumentReference { + _$ConflictDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [ConflictCollectionReference] containing this document. + ConflictCollectionReference get parent { + return _$ConflictCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(ConflictDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(ConflictDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(ConflictDocumentSnapshot._); + } + + Future set( + Conflict model, { + SetOptions? options, + FieldValue? numberFieldValue, + }) async { + final json = { + ..._$ConflictToJson(model), + if (numberFieldValue != null) + _$ConflictFieldMap['number']!: numberFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Conflict model, { + SetOptions? options, + FieldValue? numberFieldValue, + }) { + final json = { + ..._$ConflictToJson(model), + if (numberFieldValue != null) + _$ConflictFieldMap['number']!: numberFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Conflict model, { + SetOptions? options, + FieldValue? numberFieldValue, + }) { + final json = { + ..._$ConflictToJson(model), + if (numberFieldValue != null) + _$ConflictFieldMap['number']!: numberFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? number = _sentinel, + FieldValue? numberFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class ConflictQuery + implements QueryReference { + @override + ConflictQuery limit(int limit); + + @override + ConflictQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + ConflictQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ConflictQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ConflictQuery whereNumber({ + num? isEqualTo, + num? isNotEqualTo, + num? isLessThan, + num? isLessThanOrEqualTo, + num? isGreaterThan, + num? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + ConflictQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + ConflictDocumentSnapshot? startAtDocument, + ConflictDocumentSnapshot? endAtDocument, + ConflictDocumentSnapshot? endBeforeDocument, + ConflictDocumentSnapshot? startAfterDocument, + }); + + ConflictQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + ConflictDocumentSnapshot? startAtDocument, + ConflictDocumentSnapshot? endAtDocument, + ConflictDocumentSnapshot? endBeforeDocument, + ConflictDocumentSnapshot? startAfterDocument, + }); + + ConflictQuery orderByNumber({ + bool descending = false, + num startAt, + num startAfter, + num endAt, + num endBefore, + ConflictDocumentSnapshot? startAtDocument, + ConflictDocumentSnapshot? endAtDocument, + ConflictDocumentSnapshot? endBeforeDocument, + ConflictDocumentSnapshot? startAfterDocument, + }); +} + +class _$ConflictQuery extends QueryReference + implements ConflictQuery { + _$ConflictQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(ConflictQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(ConflictQuerySnapshot._fromQuerySnapshot); + } + + @override + ConflictQuery limit(int limit) { + return _$ConflictQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ConflictQuery limitToLast(int limit) { + return _$ConflictQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ConflictQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ConflictQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ConflictQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ConflictQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ConflictQuery whereNumber({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ConflictQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$ConflictFieldMap['number']!, + isEqualTo: isEqualTo != _sentinel + ? _$ConflictPerFieldToJson.number(isEqualTo as num) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$ConflictPerFieldToJson.number(isNotEqualTo as num) + : null, + isLessThan: isLessThan != null + ? _$ConflictPerFieldToJson.number(isLessThan as num) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$ConflictPerFieldToJson.number(isLessThanOrEqualTo as num) + : null, + isGreaterThan: isGreaterThan != null + ? _$ConflictPerFieldToJson.number(isGreaterThan as num) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$ConflictPerFieldToJson.number(isGreaterThanOrEqualTo as num) + : null, + whereIn: whereIn?.map((e) => _$ConflictPerFieldToJson.number(e)), + whereNotIn: whereNotIn?.map((e) => _$ConflictPerFieldToJson.number(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ConflictQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ConflictDocumentSnapshot? startAtDocument, + ConflictDocumentSnapshot? endAtDocument, + ConflictDocumentSnapshot? endBeforeDocument, + ConflictDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ConflictQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ConflictQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ConflictDocumentSnapshot? startAtDocument, + ConflictDocumentSnapshot? endAtDocument, + ConflictDocumentSnapshot? endBeforeDocument, + ConflictDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ConflictQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ConflictQuery orderByNumber({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ConflictDocumentSnapshot? startAtDocument, + ConflictDocumentSnapshot? endAtDocument, + ConflictDocumentSnapshot? endBeforeDocument, + ConflictDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$ConflictFieldMap['number']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$ConflictPerFieldToJson.number(startAt as num), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$ConflictPerFieldToJson.number(startAfter as num), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$ConflictPerFieldToJson.number(endAt as num), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$ConflictPerFieldToJson.number(endBefore as num), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ConflictQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$ConflictQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class ConflictDocumentSnapshot extends FirestoreDocumentSnapshot { + ConflictDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ConflictDocumentReference get reference { + return ConflictDocumentReference(snapshot.reference); + } + + @override + final Conflict? data; +} + +class ConflictQuerySnapshot + extends FirestoreQuerySnapshot { + ConflictQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory ConflictQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(ConflictQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, ConflictDocumentSnapshot._); + }).toList(); + + return ConflictQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ConflictDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class ConflictQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements ConflictDocumentSnapshot { + ConflictQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Conflict data; + + @override + ConflictDocumentReference get reference { + return ConflictDocumentReference(snapshot.reference); + } +} 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 0b91d2f..4984db4 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 @@ -4,967 +4,14 @@ part of 'named_query.dart'; -// ************************************************************************** -// CollectionGenerator -// ************************************************************************** - -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore -// ignore_for_file: type=lint -// ignore_for_file: invalid_use_of_internal_member - -class _Sentinel { - const _Sentinel(); -} - -const _sentinel = _Sentinel(); - -/// Adds [namedBundleTest4Get] to [FirebaseFirestore]. -extension NamedBundleTest4Extrension on FirebaseFirestore { - /// Performs [FirebaseFirestore.namedQueryGet] and decode the result into - /// a [Conflict] snashot. - Future namedBundleTest4Get({ - GetOptions options = const GetOptions(), - }) async { - final snapshot = await namedQueryWithConverterGet( - r'named-bundle-test-4', - fromFirestore: ConflictCollectionReference.fromFirestore, - toFirestore: ConflictCollectionReference.toFirestore, - options: options, - ); - return ConflictQuerySnapshot._fromQuerySnapshot(snapshot); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class ConflictCollectionReference - implements - ConflictQuery, - FirestoreCollectionReference { - factory ConflictCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ConflictCollectionReference; - - static Conflict fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$ConflictFromJson(snapshot.data()!); - } - - static Map toFirestore( - Conflict value, - SetOptions? options, - ) { - return _$ConflictToJson(value); - } - - @override - CollectionReference get reference; - - @override - ConflictDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Conflict value); -} - -class _$ConflictCollectionReference extends _$ConflictQuery - implements ConflictCollectionReference { - factory _$ConflictCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$ConflictCollectionReference._( - firestore - .collection('firestore-example-app/42/named-query-conflict') - .withConverter( - fromFirestore: ConflictCollectionReference.fromFirestore, - toFirestore: ConflictCollectionReference.toFirestore, - ), - ); - } - - _$ConflictCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - ConflictDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return ConflictDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Conflict value) { - return reference.add(value).then((ref) => ConflictDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$ConflictCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class ConflictDocumentReference - extends FirestoreDocumentReference { - factory ConflictDocumentReference(DocumentReference reference) = - _$ConflictDocumentReference; - - DocumentReference get reference; - - /// A reference to the [ConflictCollectionReference] containing this document. - ConflictCollectionReference get parent { - return _$ConflictCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Conflict model, { - SetOptions? options, - FieldValue numberFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Conflict model, { - SetOptions? options, - FieldValue numberFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Conflict model, { - SetOptions? options, - FieldValue numberFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - num number, - FieldValue numberFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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 - extends FirestoreDocumentReference - implements ConflictDocumentReference { - _$ConflictDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [ConflictCollectionReference] containing this document. - ConflictCollectionReference get parent { - return _$ConflictCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(ConflictDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(ConflictDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(ConflictDocumentSnapshot._); - } - - Future set( - Conflict model, { - SetOptions? options, - FieldValue? numberFieldValue, - }) async { - final json = { - ..._$ConflictToJson(model), - if (numberFieldValue != null) - _$ConflictFieldMap['number']!: numberFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Conflict model, { - SetOptions? options, - FieldValue? numberFieldValue, - }) { - final json = { - ..._$ConflictToJson(model), - if (numberFieldValue != null) - _$ConflictFieldMap['number']!: numberFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Conflict model, { - SetOptions? options, - FieldValue? numberFieldValue, - }) { - final json = { - ..._$ConflictToJson(model), - if (numberFieldValue != null) - _$ConflictFieldMap['number']!: numberFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? number = _sentinel, - FieldValue? numberFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class ConflictQuery - implements QueryReference { - @override - ConflictQuery limit(int limit); - - @override - ConflictQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - ConflictQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ConflictQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ConflictQuery whereNumber({ - num? isEqualTo, - num? isNotEqualTo, - num? isLessThan, - num? isLessThanOrEqualTo, - num? isGreaterThan, - num? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - ConflictQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - ConflictDocumentSnapshot? startAtDocument, - ConflictDocumentSnapshot? endAtDocument, - ConflictDocumentSnapshot? endBeforeDocument, - ConflictDocumentSnapshot? startAfterDocument, - }); - - ConflictQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - ConflictDocumentSnapshot? startAtDocument, - ConflictDocumentSnapshot? endAtDocument, - ConflictDocumentSnapshot? endBeforeDocument, - ConflictDocumentSnapshot? startAfterDocument, - }); - - ConflictQuery orderByNumber({ - bool descending = false, - num startAt, - num startAfter, - num endAt, - num endBefore, - ConflictDocumentSnapshot? startAtDocument, - ConflictDocumentSnapshot? endAtDocument, - ConflictDocumentSnapshot? endBeforeDocument, - ConflictDocumentSnapshot? startAfterDocument, - }); -} - -class _$ConflictQuery extends QueryReference - implements ConflictQuery { - _$ConflictQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(ConflictQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(ConflictQuerySnapshot._fromQuerySnapshot); - } - - @override - ConflictQuery limit(int limit) { - return _$ConflictQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ConflictQuery limitToLast(int limit) { - return _$ConflictQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ConflictQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ConflictQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ConflictQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ConflictQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ConflictQuery whereNumber({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ConflictQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$ConflictFieldMap['number']!, - isEqualTo: isEqualTo != _sentinel - ? _$ConflictPerFieldToJson.number(isEqualTo as num) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$ConflictPerFieldToJson.number(isNotEqualTo as num) - : null, - isLessThan: isLessThan != null - ? _$ConflictPerFieldToJson.number(isLessThan as num) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$ConflictPerFieldToJson.number(isLessThanOrEqualTo as num) - : null, - isGreaterThan: isGreaterThan != null - ? _$ConflictPerFieldToJson.number(isGreaterThan as num) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$ConflictPerFieldToJson.number(isGreaterThanOrEqualTo as num) - : null, - whereIn: whereIn?.map((e) => _$ConflictPerFieldToJson.number(e)), - whereNotIn: whereNotIn?.map((e) => _$ConflictPerFieldToJson.number(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ConflictQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ConflictDocumentSnapshot? startAtDocument, - ConflictDocumentSnapshot? endAtDocument, - ConflictDocumentSnapshot? endBeforeDocument, - ConflictDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ConflictQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ConflictQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ConflictDocumentSnapshot? startAtDocument, - ConflictDocumentSnapshot? endAtDocument, - ConflictDocumentSnapshot? endBeforeDocument, - ConflictDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ConflictQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ConflictQuery orderByNumber({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ConflictDocumentSnapshot? startAtDocument, - ConflictDocumentSnapshot? endAtDocument, - ConflictDocumentSnapshot? endBeforeDocument, - ConflictDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$ConflictFieldMap['number']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ConflictQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$ConflictQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class ConflictDocumentSnapshot extends FirestoreDocumentSnapshot { - ConflictDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - ConflictDocumentReference get reference { - return ConflictDocumentReference( - snapshot.reference, - ); - } - - @override - final Conflict? data; -} - -class ConflictQuerySnapshot - extends FirestoreQuerySnapshot { - ConflictQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory ConflictQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(ConflictQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ConflictDocumentSnapshot._, - ); - }).toList(); - - return ConflictQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - ConflictDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class ConflictQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements ConflictDocumentSnapshot { - ConflictQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Conflict data; - - @override - ConflictDocumentReference get reference { - return ConflictDocumentReference(snapshot.reference); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -Conflict _$ConflictFromJson(Map json) => Conflict( - json['number'] as num, - ); +Conflict _$ConflictFromJson(Map json) => + Conflict(json['number'] as num); -const _$ConflictFieldMap = { - 'number': 'number', -}; +const _$ConflictFieldMap = {'number': 'number'}; // ignore: unused_element abstract class _$ConflictPerFieldToJson { @@ -973,5 +20,5 @@ abstract class _$ConflictPerFieldToJson { } Map _$ConflictToJson(Conflict instance) => { - 'number': instance.number, - }; + 'number': instance.number, +}; diff --git a/packages/cloud_firestore_odm/example/lib/integration/query.dart b/packages/cloud_firestore_odm/example/lib/integration/query.dart index 9440716..a25c663 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/query.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/query.dart @@ -6,6 +6,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:json_annotation/json_annotation.dart'; +part 'query.firebase.dart'; part 'query.g.dart'; @Collection('firestore-example-app/42/duration') diff --git a/packages/cloud_firestore_odm/example/lib/integration/query.firebase.dart b/packages/cloud_firestore_odm/example/lib/integration/query.firebase.dart new file mode 100644 index 0000000..d8906c0 --- /dev/null +++ b/packages/cloud_firestore_odm/example/lib/integration/query.firebase.dart @@ -0,0 +1,4897 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'query.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class DurationQueryCollectionReference + implements + DurationQueryQuery, + FirestoreCollectionReference< + DurationQuery, + DurationQueryQuerySnapshot + > { + factory DurationQueryCollectionReference([FirebaseFirestore? firestore]) = + _$DurationQueryCollectionReference; + + static DurationQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$DurationQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + DurationQuery value, + SetOptions? options, + ) { + return _$DurationQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + DurationQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(DurationQuery value); +} + +class _$DurationQueryCollectionReference extends _$DurationQueryQuery + implements DurationQueryCollectionReference { + factory _$DurationQueryCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$DurationQueryCollectionReference._( + firestore + .collection('firestore-example-app/42/duration') + .withConverter( + fromFirestore: DurationQueryCollectionReference.fromFirestore, + toFirestore: DurationQueryCollectionReference.toFirestore, + ), + ); + } + + _$DurationQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + DurationQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return DurationQueryDocumentReference(reference.doc(id)); + } + + @override + Future add(DurationQuery value) { + return reference + .add(value) + .then((ref) => DurationQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$DurationQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class DurationQueryDocumentReference + extends + FirestoreDocumentReference< + DurationQuery, + DurationQueryDocumentSnapshot + > { + factory DurationQueryDocumentReference( + DocumentReference reference, + ) = _$DurationQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [DurationQueryCollectionReference] containing this document. + DurationQueryCollectionReference get parent { + return _$DurationQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + DurationQuery model, { + SetOptions? options, + FieldValue durationFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + DurationQuery model, { + SetOptions? options, + FieldValue durationFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + DurationQuery model, { + SetOptions? options, + FieldValue durationFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({Duration duration, FieldValue durationFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + implements DurationQueryDocumentReference { + _$DurationQueryDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [DurationQueryCollectionReference] containing this document. + DurationQueryCollectionReference get parent { + return _$DurationQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(DurationQueryDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(DurationQueryDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(DurationQueryDocumentSnapshot._); + } + + Future set( + DurationQuery model, { + SetOptions? options, + FieldValue? durationFieldValue, + }) async { + final json = { + ..._$DurationQueryToJson(model), + if (durationFieldValue != null) + _$DurationQueryFieldMap['duration']!: durationFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + DurationQuery model, { + SetOptions? options, + FieldValue? durationFieldValue, + }) { + final json = { + ..._$DurationQueryToJson(model), + if (durationFieldValue != null) + _$DurationQueryFieldMap['duration']!: durationFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + DurationQuery model, { + SetOptions? options, + FieldValue? durationFieldValue, + }) { + final json = { + ..._$DurationQueryToJson(model), + if (durationFieldValue != null) + _$DurationQueryFieldMap['duration']!: durationFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? duration = _sentinel, + FieldValue? durationFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class DurationQueryQuery + implements QueryReference { + @override + DurationQueryQuery limit(int limit); + + @override + DurationQueryQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + DurationQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + DurationQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + DurationQueryQuery whereDuration({ + Duration? isEqualTo, + Duration? isNotEqualTo, + Duration? isLessThan, + Duration? isLessThanOrEqualTo, + Duration? isGreaterThan, + Duration? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + DurationQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + DurationQueryDocumentSnapshot? startAtDocument, + DurationQueryDocumentSnapshot? endAtDocument, + DurationQueryDocumentSnapshot? endBeforeDocument, + DurationQueryDocumentSnapshot? startAfterDocument, + }); + + DurationQueryQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + DurationQueryDocumentSnapshot? startAtDocument, + DurationQueryDocumentSnapshot? endAtDocument, + DurationQueryDocumentSnapshot? endBeforeDocument, + DurationQueryDocumentSnapshot? startAfterDocument, + }); + + DurationQueryQuery orderByDuration({ + bool descending = false, + Duration startAt, + Duration startAfter, + Duration endAt, + Duration endBefore, + DurationQueryDocumentSnapshot? startAtDocument, + DurationQueryDocumentSnapshot? endAtDocument, + DurationQueryDocumentSnapshot? endBeforeDocument, + DurationQueryDocumentSnapshot? startAfterDocument, + }); +} + +class _$DurationQueryQuery + extends QueryReference + implements DurationQueryQuery { + _$DurationQueryQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + DurationQueryQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(DurationQueryQuerySnapshot._fromQuerySnapshot); + } + + @override + DurationQueryQuery limit(int limit) { + return _$DurationQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + DurationQueryQuery limitToLast(int limit) { + return _$DurationQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + DurationQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$DurationQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DurationQueryQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$DurationQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DurationQueryQuery whereDuration({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$DurationQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$DurationQueryFieldMap['duration']!, + isEqualTo: isEqualTo != _sentinel + ? _$DurationQueryPerFieldToJson.duration(isEqualTo as Duration) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$DurationQueryPerFieldToJson.duration(isNotEqualTo as Duration) + : null, + isLessThan: isLessThan != null + ? _$DurationQueryPerFieldToJson.duration(isLessThan as Duration) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$DurationQueryPerFieldToJson.duration( + isLessThanOrEqualTo as Duration, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$DurationQueryPerFieldToJson.duration(isGreaterThan as Duration) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$DurationQueryPerFieldToJson.duration( + isGreaterThanOrEqualTo as Duration, + ) + : null, + whereIn: whereIn?.map((e) => _$DurationQueryPerFieldToJson.duration(e)), + whereNotIn: whereNotIn?.map( + (e) => _$DurationQueryPerFieldToJson.duration(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DurationQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DurationQueryDocumentSnapshot? startAtDocument, + DurationQueryDocumentSnapshot? endAtDocument, + DurationQueryDocumentSnapshot? endBeforeDocument, + DurationQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DurationQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + DurationQueryQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DurationQueryDocumentSnapshot? startAtDocument, + DurationQueryDocumentSnapshot? endAtDocument, + DurationQueryDocumentSnapshot? endBeforeDocument, + DurationQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DurationQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + DurationQueryQuery orderByDuration({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DurationQueryDocumentSnapshot? startAtDocument, + DurationQueryDocumentSnapshot? endAtDocument, + DurationQueryDocumentSnapshot? endBeforeDocument, + DurationQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$DurationQueryFieldMap['duration']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$DurationQueryPerFieldToJson.duration(startAt as Duration), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$DurationQueryPerFieldToJson.duration(startAfter as Duration), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$DurationQueryPerFieldToJson.duration(endAt as Duration), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$DurationQueryPerFieldToJson.duration(endBefore as Duration), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DurationQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$DurationQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class DurationQueryDocumentSnapshot + extends FirestoreDocumentSnapshot { + DurationQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + DurationQueryDocumentReference get reference { + return DurationQueryDocumentReference(snapshot.reference); + } + + @override + final DurationQuery? data; +} + +class DurationQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + DurationQuery, + DurationQueryQueryDocumentSnapshot + > { + DurationQueryQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory DurationQueryQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(DurationQueryQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, DurationQueryDocumentSnapshot._); + }).toList(); + + return DurationQueryQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + DurationQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class DurationQueryQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements DurationQueryDocumentSnapshot { + DurationQueryQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final DurationQuery data; + + @override + DurationQueryDocumentReference get reference { + return DurationQueryDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class DateTimeQueryCollectionReference + implements + DateTimeQueryQuery, + FirestoreCollectionReference< + DateTimeQuery, + DateTimeQueryQuerySnapshot + > { + factory DateTimeQueryCollectionReference([FirebaseFirestore? firestore]) = + _$DateTimeQueryCollectionReference; + + static DateTimeQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$DateTimeQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + DateTimeQuery value, + SetOptions? options, + ) { + return _$DateTimeQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + DateTimeQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(DateTimeQuery value); +} + +class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery + implements DateTimeQueryCollectionReference { + factory _$DateTimeQueryCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$DateTimeQueryCollectionReference._( + firestore + .collection('firestore-example-app/42/date-time') + .withConverter( + fromFirestore: DateTimeQueryCollectionReference.fromFirestore, + toFirestore: DateTimeQueryCollectionReference.toFirestore, + ), + ); + } + + _$DateTimeQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + DateTimeQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return DateTimeQueryDocumentReference(reference.doc(id)); + } + + @override + Future add(DateTimeQuery value) { + return reference + .add(value) + .then((ref) => DateTimeQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$DateTimeQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class DateTimeQueryDocumentReference + extends + FirestoreDocumentReference< + DateTimeQuery, + DateTimeQueryDocumentSnapshot + > { + factory DateTimeQueryDocumentReference( + DocumentReference reference, + ) = _$DateTimeQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [DateTimeQueryCollectionReference] containing this document. + DateTimeQueryCollectionReference get parent { + return _$DateTimeQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + DateTimeQuery model, { + SetOptions? options, + FieldValue timeFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + DateTimeQuery model, { + SetOptions? options, + FieldValue timeFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + DateTimeQuery model, { + SetOptions? options, + FieldValue timeFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({DateTime time, FieldValue timeFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + implements DateTimeQueryDocumentReference { + _$DateTimeQueryDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [DateTimeQueryCollectionReference] containing this document. + DateTimeQueryCollectionReference get parent { + return _$DateTimeQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(DateTimeQueryDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(DateTimeQueryDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(DateTimeQueryDocumentSnapshot._); + } + + Future set( + DateTimeQuery model, { + SetOptions? options, + FieldValue? timeFieldValue, + }) async { + final json = { + ..._$DateTimeQueryToJson(model), + if (timeFieldValue != null) + _$DateTimeQueryFieldMap['time']!: timeFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + DateTimeQuery model, { + SetOptions? options, + FieldValue? timeFieldValue, + }) { + final json = { + ..._$DateTimeQueryToJson(model), + if (timeFieldValue != null) + _$DateTimeQueryFieldMap['time']!: timeFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + DateTimeQuery model, { + SetOptions? options, + FieldValue? timeFieldValue, + }) { + final json = { + ..._$DateTimeQueryToJson(model), + if (timeFieldValue != null) + _$DateTimeQueryFieldMap['time']!: timeFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? time = _sentinel, + FieldValue? timeFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class DateTimeQueryQuery + implements QueryReference { + @override + DateTimeQueryQuery limit(int limit); + + @override + DateTimeQueryQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + DateTimeQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + DateTimeQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + DateTimeQueryQuery whereTime({ + DateTime? isEqualTo, + DateTime? isNotEqualTo, + DateTime? isLessThan, + DateTime? isLessThanOrEqualTo, + DateTime? isGreaterThan, + DateTime? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + DateTimeQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + DateTimeQueryDocumentSnapshot? startAtDocument, + DateTimeQueryDocumentSnapshot? endAtDocument, + DateTimeQueryDocumentSnapshot? endBeforeDocument, + DateTimeQueryDocumentSnapshot? startAfterDocument, + }); + + DateTimeQueryQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + DateTimeQueryDocumentSnapshot? startAtDocument, + DateTimeQueryDocumentSnapshot? endAtDocument, + DateTimeQueryDocumentSnapshot? endBeforeDocument, + DateTimeQueryDocumentSnapshot? startAfterDocument, + }); + + DateTimeQueryQuery orderByTime({ + bool descending = false, + DateTime startAt, + DateTime startAfter, + DateTime endAt, + DateTime endBefore, + DateTimeQueryDocumentSnapshot? startAtDocument, + DateTimeQueryDocumentSnapshot? endAtDocument, + DateTimeQueryDocumentSnapshot? endBeforeDocument, + DateTimeQueryDocumentSnapshot? startAfterDocument, + }); +} + +class _$DateTimeQueryQuery + extends QueryReference + implements DateTimeQueryQuery { + _$DateTimeQueryQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + DateTimeQueryQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(DateTimeQueryQuerySnapshot._fromQuerySnapshot); + } + + @override + DateTimeQueryQuery limit(int limit) { + return _$DateTimeQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + DateTimeQueryQuery limitToLast(int limit) { + return _$DateTimeQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + DateTimeQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$DateTimeQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DateTimeQueryQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$DateTimeQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DateTimeQueryQuery whereTime({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$DateTimeQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$DateTimeQueryFieldMap['time']!, + isEqualTo: isEqualTo != _sentinel + ? _$DateTimeQueryPerFieldToJson.time(isEqualTo as DateTime) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$DateTimeQueryPerFieldToJson.time(isNotEqualTo as DateTime) + : null, + isLessThan: isLessThan != null + ? _$DateTimeQueryPerFieldToJson.time(isLessThan as DateTime) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$DateTimeQueryPerFieldToJson.time( + isLessThanOrEqualTo as DateTime, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$DateTimeQueryPerFieldToJson.time(isGreaterThan as DateTime) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$DateTimeQueryPerFieldToJson.time( + isGreaterThanOrEqualTo as DateTime, + ) + : null, + whereIn: whereIn?.map((e) => _$DateTimeQueryPerFieldToJson.time(e)), + whereNotIn: whereNotIn?.map( + (e) => _$DateTimeQueryPerFieldToJson.time(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DateTimeQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DateTimeQueryDocumentSnapshot? startAtDocument, + DateTimeQueryDocumentSnapshot? endAtDocument, + DateTimeQueryDocumentSnapshot? endBeforeDocument, + DateTimeQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DateTimeQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + DateTimeQueryQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DateTimeQueryDocumentSnapshot? startAtDocument, + DateTimeQueryDocumentSnapshot? endAtDocument, + DateTimeQueryDocumentSnapshot? endBeforeDocument, + DateTimeQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DateTimeQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + DateTimeQueryQuery orderByTime({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DateTimeQueryDocumentSnapshot? startAtDocument, + DateTimeQueryDocumentSnapshot? endAtDocument, + DateTimeQueryDocumentSnapshot? endBeforeDocument, + DateTimeQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$DateTimeQueryFieldMap['time']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$DateTimeQueryPerFieldToJson.time(startAt as DateTime), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$DateTimeQueryPerFieldToJson.time(startAfter as DateTime), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$DateTimeQueryPerFieldToJson.time(endAt as DateTime), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$DateTimeQueryPerFieldToJson.time(endBefore as DateTime), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DateTimeQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$DateTimeQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class DateTimeQueryDocumentSnapshot + extends FirestoreDocumentSnapshot { + DateTimeQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + DateTimeQueryDocumentReference get reference { + return DateTimeQueryDocumentReference(snapshot.reference); + } + + @override + final DateTimeQuery? data; +} + +class DateTimeQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + DateTimeQuery, + DateTimeQueryQueryDocumentSnapshot + > { + DateTimeQueryQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory DateTimeQueryQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(DateTimeQueryQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, DateTimeQueryDocumentSnapshot._); + }).toList(); + + return DateTimeQueryQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + DateTimeQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class DateTimeQueryQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements DateTimeQueryDocumentSnapshot { + DateTimeQueryQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final DateTimeQuery data; + + @override + DateTimeQueryDocumentReference get reference { + return DateTimeQueryDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class TimestampQueryCollectionReference + implements + TimestampQueryQuery, + FirestoreCollectionReference< + TimestampQuery, + TimestampQueryQuerySnapshot + > { + factory TimestampQueryCollectionReference([FirebaseFirestore? firestore]) = + _$TimestampQueryCollectionReference; + + static TimestampQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$TimestampQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + TimestampQuery value, + SetOptions? options, + ) { + return _$TimestampQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + TimestampQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(TimestampQuery value); +} + +class _$TimestampQueryCollectionReference extends _$TimestampQueryQuery + implements TimestampQueryCollectionReference { + factory _$TimestampQueryCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$TimestampQueryCollectionReference._( + firestore + .collection('firestore-example-app/42/timestamp-time') + .withConverter( + fromFirestore: TimestampQueryCollectionReference.fromFirestore, + toFirestore: TimestampQueryCollectionReference.toFirestore, + ), + ); + } + + _$TimestampQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + TimestampQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return TimestampQueryDocumentReference(reference.doc(id)); + } + + @override + Future add(TimestampQuery value) { + return reference + .add(value) + .then((ref) => TimestampQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$TimestampQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class TimestampQueryDocumentReference + extends + FirestoreDocumentReference< + TimestampQuery, + TimestampQueryDocumentSnapshot + > { + factory TimestampQueryDocumentReference( + DocumentReference reference, + ) = _$TimestampQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [TimestampQueryCollectionReference] containing this document. + TimestampQueryCollectionReference get parent { + return _$TimestampQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + TimestampQuery model, { + SetOptions? options, + FieldValue timeFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + TimestampQuery model, { + SetOptions? options, + FieldValue timeFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + TimestampQuery model, { + SetOptions? options, + FieldValue timeFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({Timestamp time, FieldValue timeFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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< + TimestampQuery, + TimestampQueryDocumentSnapshot + > + implements TimestampQueryDocumentReference { + _$TimestampQueryDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [TimestampQueryCollectionReference] containing this document. + TimestampQueryCollectionReference get parent { + return _$TimestampQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(TimestampQueryDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(TimestampQueryDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(TimestampQueryDocumentSnapshot._); + } + + Future set( + TimestampQuery model, { + SetOptions? options, + FieldValue? timeFieldValue, + }) async { + final json = { + ..._$TimestampQueryToJson(model), + if (timeFieldValue != null) + _$TimestampQueryFieldMap['time']!: timeFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + TimestampQuery model, { + SetOptions? options, + FieldValue? timeFieldValue, + }) { + final json = { + ..._$TimestampQueryToJson(model), + if (timeFieldValue != null) + _$TimestampQueryFieldMap['time']!: timeFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + TimestampQuery model, { + SetOptions? options, + FieldValue? timeFieldValue, + }) { + final json = { + ..._$TimestampQueryToJson(model), + if (timeFieldValue != null) + _$TimestampQueryFieldMap['time']!: timeFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? time = _sentinel, + FieldValue? timeFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class TimestampQueryQuery + implements QueryReference { + @override + TimestampQueryQuery limit(int limit); + + @override + TimestampQueryQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + TimestampQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + TimestampQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + TimestampQueryQuery whereTime({ + Timestamp? isEqualTo, + Timestamp? isNotEqualTo, + Timestamp? isLessThan, + Timestamp? isLessThanOrEqualTo, + Timestamp? isGreaterThan, + Timestamp? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + TimestampQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + TimestampQueryDocumentSnapshot? startAtDocument, + TimestampQueryDocumentSnapshot? endAtDocument, + TimestampQueryDocumentSnapshot? endBeforeDocument, + TimestampQueryDocumentSnapshot? startAfterDocument, + }); + + TimestampQueryQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + TimestampQueryDocumentSnapshot? startAtDocument, + TimestampQueryDocumentSnapshot? endAtDocument, + TimestampQueryDocumentSnapshot? endBeforeDocument, + TimestampQueryDocumentSnapshot? startAfterDocument, + }); + + TimestampQueryQuery orderByTime({ + bool descending = false, + Timestamp startAt, + Timestamp startAfter, + Timestamp endAt, + Timestamp endBefore, + TimestampQueryDocumentSnapshot? startAtDocument, + TimestampQueryDocumentSnapshot? endAtDocument, + TimestampQueryDocumentSnapshot? endBeforeDocument, + TimestampQueryDocumentSnapshot? startAfterDocument, + }); +} + +class _$TimestampQueryQuery + extends QueryReference + implements TimestampQueryQuery { + _$TimestampQueryQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + TimestampQueryQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(TimestampQueryQuerySnapshot._fromQuerySnapshot); + } + + @override + TimestampQueryQuery limit(int limit) { + return _$TimestampQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + TimestampQueryQuery limitToLast(int limit) { + return _$TimestampQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + TimestampQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$TimestampQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + TimestampQueryQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$TimestampQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + TimestampQueryQuery whereTime({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$TimestampQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$TimestampQueryFieldMap['time']!, + isEqualTo: isEqualTo != _sentinel + ? _$TimestampQueryPerFieldToJson.time(isEqualTo as Timestamp) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$TimestampQueryPerFieldToJson.time(isNotEqualTo as Timestamp) + : null, + isLessThan: isLessThan != null + ? _$TimestampQueryPerFieldToJson.time(isLessThan as Timestamp) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$TimestampQueryPerFieldToJson.time( + isLessThanOrEqualTo as Timestamp, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$TimestampQueryPerFieldToJson.time(isGreaterThan as Timestamp) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$TimestampQueryPerFieldToJson.time( + isGreaterThanOrEqualTo as Timestamp, + ) + : null, + whereIn: whereIn?.map((e) => _$TimestampQueryPerFieldToJson.time(e)), + whereNotIn: whereNotIn?.map( + (e) => _$TimestampQueryPerFieldToJson.time(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + TimestampQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + TimestampQueryDocumentSnapshot? startAtDocument, + TimestampQueryDocumentSnapshot? endAtDocument, + TimestampQueryDocumentSnapshot? endBeforeDocument, + TimestampQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$TimestampQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + TimestampQueryQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + TimestampQueryDocumentSnapshot? startAtDocument, + TimestampQueryDocumentSnapshot? endAtDocument, + TimestampQueryDocumentSnapshot? endBeforeDocument, + TimestampQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$TimestampQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + TimestampQueryQuery orderByTime({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + TimestampQueryDocumentSnapshot? startAtDocument, + TimestampQueryDocumentSnapshot? endAtDocument, + TimestampQueryDocumentSnapshot? endBeforeDocument, + TimestampQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$TimestampQueryFieldMap['time']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$TimestampQueryPerFieldToJson.time(startAt as Timestamp), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$TimestampQueryPerFieldToJson.time(startAfter as Timestamp), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$TimestampQueryPerFieldToJson.time(endAt as Timestamp), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$TimestampQueryPerFieldToJson.time(endBefore as Timestamp), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$TimestampQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$TimestampQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class TimestampQueryDocumentSnapshot + extends FirestoreDocumentSnapshot { + TimestampQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + TimestampQueryDocumentReference get reference { + return TimestampQueryDocumentReference(snapshot.reference); + } + + @override + final TimestampQuery? data; +} + +class TimestampQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + TimestampQuery, + TimestampQueryQueryDocumentSnapshot + > { + TimestampQueryQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory TimestampQueryQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(TimestampQueryQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, TimestampQueryDocumentSnapshot._); + }).toList(); + + return TimestampQueryQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + TimestampQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> + docChanges; +} + +class TimestampQueryQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements TimestampQueryDocumentSnapshot { + TimestampQueryQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final TimestampQuery data; + + @override + TimestampQueryDocumentReference get reference { + return TimestampQueryDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class GeoPointQueryCollectionReference + implements + GeoPointQueryQuery, + FirestoreCollectionReference< + GeoPointQuery, + GeoPointQueryQuerySnapshot + > { + factory GeoPointQueryCollectionReference([FirebaseFirestore? firestore]) = + _$GeoPointQueryCollectionReference; + + static GeoPointQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$GeoPointQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + GeoPointQuery value, + SetOptions? options, + ) { + return _$GeoPointQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + GeoPointQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(GeoPointQuery value); +} + +class _$GeoPointQueryCollectionReference extends _$GeoPointQueryQuery + implements GeoPointQueryCollectionReference { + factory _$GeoPointQueryCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$GeoPointQueryCollectionReference._( + firestore + .collection('firestore-example-app/42/geopoint-time') + .withConverter( + fromFirestore: GeoPointQueryCollectionReference.fromFirestore, + toFirestore: GeoPointQueryCollectionReference.toFirestore, + ), + ); + } + + _$GeoPointQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + GeoPointQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return GeoPointQueryDocumentReference(reference.doc(id)); + } + + @override + Future add(GeoPointQuery value) { + return reference + .add(value) + .then((ref) => GeoPointQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$GeoPointQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class GeoPointQueryDocumentReference + extends + FirestoreDocumentReference< + GeoPointQuery, + GeoPointQueryDocumentSnapshot + > { + factory GeoPointQueryDocumentReference( + DocumentReference reference, + ) = _$GeoPointQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [GeoPointQueryCollectionReference] containing this document. + GeoPointQueryCollectionReference get parent { + return _$GeoPointQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + GeoPointQuery model, { + SetOptions? options, + FieldValue pointFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + GeoPointQuery model, { + SetOptions? options, + FieldValue pointFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + GeoPointQuery model, { + SetOptions? options, + FieldValue pointFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({GeoPoint point, FieldValue pointFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + implements GeoPointQueryDocumentReference { + _$GeoPointQueryDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [GeoPointQueryCollectionReference] containing this document. + GeoPointQueryCollectionReference get parent { + return _$GeoPointQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(GeoPointQueryDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(GeoPointQueryDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(GeoPointQueryDocumentSnapshot._); + } + + Future set( + GeoPointQuery model, { + SetOptions? options, + FieldValue? pointFieldValue, + }) async { + final json = { + ..._$GeoPointQueryToJson(model), + if (pointFieldValue != null) + _$GeoPointQueryFieldMap['point']!: pointFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + GeoPointQuery model, { + SetOptions? options, + FieldValue? pointFieldValue, + }) { + final json = { + ..._$GeoPointQueryToJson(model), + if (pointFieldValue != null) + _$GeoPointQueryFieldMap['point']!: pointFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + GeoPointQuery model, { + SetOptions? options, + FieldValue? pointFieldValue, + }) { + final json = { + ..._$GeoPointQueryToJson(model), + if (pointFieldValue != null) + _$GeoPointQueryFieldMap['point']!: pointFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? point = _sentinel, + FieldValue? pointFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class GeoPointQueryQuery + implements QueryReference { + @override + GeoPointQueryQuery limit(int limit); + + @override + GeoPointQueryQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + GeoPointQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + GeoPointQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + GeoPointQueryQuery wherePoint({ + GeoPoint? isEqualTo, + GeoPoint? isNotEqualTo, + GeoPoint? isLessThan, + GeoPoint? isLessThanOrEqualTo, + GeoPoint? isGreaterThan, + GeoPoint? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + GeoPointQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + GeoPointQueryDocumentSnapshot? startAtDocument, + GeoPointQueryDocumentSnapshot? endAtDocument, + GeoPointQueryDocumentSnapshot? endBeforeDocument, + GeoPointQueryDocumentSnapshot? startAfterDocument, + }); + + GeoPointQueryQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + GeoPointQueryDocumentSnapshot? startAtDocument, + GeoPointQueryDocumentSnapshot? endAtDocument, + GeoPointQueryDocumentSnapshot? endBeforeDocument, + GeoPointQueryDocumentSnapshot? startAfterDocument, + }); + + GeoPointQueryQuery orderByPoint({ + bool descending = false, + GeoPoint startAt, + GeoPoint startAfter, + GeoPoint endAt, + GeoPoint endBefore, + GeoPointQueryDocumentSnapshot? startAtDocument, + GeoPointQueryDocumentSnapshot? endAtDocument, + GeoPointQueryDocumentSnapshot? endBeforeDocument, + GeoPointQueryDocumentSnapshot? startAfterDocument, + }); +} + +class _$GeoPointQueryQuery + extends QueryReference + implements GeoPointQueryQuery { + _$GeoPointQueryQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + GeoPointQueryQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(GeoPointQueryQuerySnapshot._fromQuerySnapshot); + } + + @override + GeoPointQueryQuery limit(int limit) { + return _$GeoPointQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + GeoPointQueryQuery limitToLast(int limit) { + return _$GeoPointQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + GeoPointQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$GeoPointQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + GeoPointQueryQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$GeoPointQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + GeoPointQueryQuery wherePoint({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$GeoPointQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$GeoPointQueryFieldMap['point']!, + isEqualTo: isEqualTo != _sentinel + ? _$GeoPointQueryPerFieldToJson.point(isEqualTo as GeoPoint) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$GeoPointQueryPerFieldToJson.point(isNotEqualTo as GeoPoint) + : null, + isLessThan: isLessThan != null + ? _$GeoPointQueryPerFieldToJson.point(isLessThan as GeoPoint) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$GeoPointQueryPerFieldToJson.point( + isLessThanOrEqualTo as GeoPoint, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$GeoPointQueryPerFieldToJson.point(isGreaterThan as GeoPoint) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$GeoPointQueryPerFieldToJson.point( + isGreaterThanOrEqualTo as GeoPoint, + ) + : null, + whereIn: whereIn?.map((e) => _$GeoPointQueryPerFieldToJson.point(e)), + whereNotIn: whereNotIn?.map( + (e) => _$GeoPointQueryPerFieldToJson.point(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + GeoPointQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + GeoPointQueryDocumentSnapshot? startAtDocument, + GeoPointQueryDocumentSnapshot? endAtDocument, + GeoPointQueryDocumentSnapshot? endBeforeDocument, + GeoPointQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$GeoPointQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + GeoPointQueryQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + GeoPointQueryDocumentSnapshot? startAtDocument, + GeoPointQueryDocumentSnapshot? endAtDocument, + GeoPointQueryDocumentSnapshot? endBeforeDocument, + GeoPointQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$GeoPointQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + GeoPointQueryQuery orderByPoint({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + GeoPointQueryDocumentSnapshot? startAtDocument, + GeoPointQueryDocumentSnapshot? endAtDocument, + GeoPointQueryDocumentSnapshot? endBeforeDocument, + GeoPointQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$GeoPointQueryFieldMap['point']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$GeoPointQueryPerFieldToJson.point(startAt as GeoPoint), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$GeoPointQueryPerFieldToJson.point(startAfter as GeoPoint), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$GeoPointQueryPerFieldToJson.point(endAt as GeoPoint), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$GeoPointQueryPerFieldToJson.point(endBefore as GeoPoint), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$GeoPointQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$GeoPointQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class GeoPointQueryDocumentSnapshot + extends FirestoreDocumentSnapshot { + GeoPointQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + GeoPointQueryDocumentReference get reference { + return GeoPointQueryDocumentReference(snapshot.reference); + } + + @override + final GeoPointQuery? data; +} + +class GeoPointQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + GeoPointQuery, + GeoPointQueryQueryDocumentSnapshot + > { + GeoPointQueryQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory GeoPointQueryQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(GeoPointQueryQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, GeoPointQueryDocumentSnapshot._); + }).toList(); + + return GeoPointQueryQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + GeoPointQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class GeoPointQueryQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements GeoPointQueryDocumentSnapshot { + GeoPointQueryQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final GeoPointQuery data; + + @override + GeoPointQueryDocumentReference get reference { + return GeoPointQueryDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class DocumentReferenceQueryCollectionReference + implements + DocumentReferenceQueryQuery, + FirestoreCollectionReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > { + factory DocumentReferenceQueryCollectionReference([ + FirebaseFirestore? firestore, + ]) = _$DocumentReferenceQueryCollectionReference; + + static DocumentReferenceQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$DocumentReferenceQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + DocumentReferenceQuery value, + SetOptions? options, + ) { + return _$DocumentReferenceQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + DocumentReferenceQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add( + DocumentReferenceQuery value, + ); +} + +class _$DocumentReferenceQueryCollectionReference + extends _$DocumentReferenceQueryQuery + implements DocumentReferenceQueryCollectionReference { + factory _$DocumentReferenceQueryCollectionReference([ + FirebaseFirestore? firestore, + ]) { + firestore ??= FirebaseFirestore.instance; + + return _$DocumentReferenceQueryCollectionReference._( + firestore + .collection('firestore-example-app/42/doc-ref') + .withConverter( + fromFirestore: + DocumentReferenceQueryCollectionReference.fromFirestore, + toFirestore: DocumentReferenceQueryCollectionReference.toFirestore, + ), + ); + } + + _$DocumentReferenceQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + DocumentReferenceQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return DocumentReferenceQueryDocumentReference(reference.doc(id)); + } + + @override + Future add( + DocumentReferenceQuery value, + ) { + return reference + .add(value) + .then((ref) => DocumentReferenceQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$DocumentReferenceQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class DocumentReferenceQueryDocumentReference + extends + FirestoreDocumentReference< + DocumentReferenceQuery, + DocumentReferenceQueryDocumentSnapshot + > { + factory DocumentReferenceQueryDocumentReference( + DocumentReference reference, + ) = _$DocumentReferenceQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [DocumentReferenceQueryCollectionReference] containing this document. + DocumentReferenceQueryCollectionReference get parent { + return _$DocumentReferenceQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + DocumentReferenceQuery model, { + SetOptions? options, + FieldValue refFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + DocumentReferenceQuery model, { + SetOptions? options, + FieldValue refFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + DocumentReferenceQuery model, { + SetOptions? options, + FieldValue refFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + DocumentReference> ref, + FieldValue refFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + extends + FirestoreDocumentReference< + DocumentReferenceQuery, + DocumentReferenceQueryDocumentSnapshot + > + implements DocumentReferenceQueryDocumentReference { + _$DocumentReferenceQueryDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [DocumentReferenceQueryCollectionReference] containing this document. + DocumentReferenceQueryCollectionReference get parent { + return _$DocumentReferenceQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(DocumentReferenceQueryDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(DocumentReferenceQueryDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction + .get(reference) + .then(DocumentReferenceQueryDocumentSnapshot._); + } + + Future set( + DocumentReferenceQuery model, { + SetOptions? options, + FieldValue? refFieldValue, + }) async { + final json = { + ..._$DocumentReferenceQueryToJson(model), + if (refFieldValue != null) + _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + DocumentReferenceQuery model, { + SetOptions? options, + FieldValue? refFieldValue, + }) { + final json = { + ..._$DocumentReferenceQueryToJson(model), + if (refFieldValue != null) + _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + DocumentReferenceQuery model, { + SetOptions? options, + FieldValue? refFieldValue, + }) { + final json = { + ..._$DocumentReferenceQueryToJson(model), + if (refFieldValue != null) + _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? ref = _sentinel, + FieldValue? refFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class DocumentReferenceQueryQuery + implements + QueryReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > { + @override + DocumentReferenceQueryQuery limit(int limit); + + @override + DocumentReferenceQueryQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + DocumentReferenceQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + DocumentReferenceQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + DocumentReferenceQueryQuery whereRef({ + DocumentReference>? isEqualTo, + DocumentReference>? isNotEqualTo, + DocumentReference>? isLessThan, + DocumentReference>? isLessThanOrEqualTo, + DocumentReference>? isGreaterThan, + DocumentReference>? isGreaterThanOrEqualTo, + List>>? whereIn, + List>>? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + DocumentReferenceQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + DocumentReferenceQueryDocumentSnapshot? startAtDocument, + DocumentReferenceQueryDocumentSnapshot? endAtDocument, + DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, + DocumentReferenceQueryDocumentSnapshot? startAfterDocument, + }); + + DocumentReferenceQueryQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + DocumentReferenceQueryDocumentSnapshot? startAtDocument, + DocumentReferenceQueryDocumentSnapshot? endAtDocument, + DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, + DocumentReferenceQueryDocumentSnapshot? startAfterDocument, + }); + + DocumentReferenceQueryQuery orderByRef({ + bool descending = false, + DocumentReference> startAt, + DocumentReference> startAfter, + DocumentReference> endAt, + DocumentReference> endBefore, + DocumentReferenceQueryDocumentSnapshot? startAtDocument, + DocumentReferenceQueryDocumentSnapshot? endAtDocument, + DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, + DocumentReferenceQueryDocumentSnapshot? startAfterDocument, + }); +} + +class _$DocumentReferenceQueryQuery + extends + QueryReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > + implements DocumentReferenceQueryQuery { + _$DocumentReferenceQueryQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot); + } + + @override + DocumentReferenceQueryQuery limit(int limit) { + return _$DocumentReferenceQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + DocumentReferenceQueryQuery limitToLast(int limit) { + return _$DocumentReferenceQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + DocumentReferenceQueryQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$DocumentReferenceQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DocumentReferenceQueryQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$DocumentReferenceQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DocumentReferenceQueryQuery whereRef({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List>>? whereIn, + List>>? whereNotIn, + bool? isNull, + }) { + return _$DocumentReferenceQueryQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$DocumentReferenceQueryFieldMap['ref']!, + isEqualTo: isEqualTo != _sentinel + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isEqualTo as DocumentReference>, + ) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isNotEqualTo as DocumentReference>, + ) + : null, + isLessThan: isLessThan != null + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isLessThan as DocumentReference>, + ) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isLessThanOrEqualTo as DocumentReference>, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isGreaterThan as DocumentReference>, + ) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isGreaterThanOrEqualTo + as DocumentReference>, + ) + : null, + whereIn: whereIn?.map( + (e) => _$DocumentReferenceQueryPerFieldToJson.ref(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$DocumentReferenceQueryPerFieldToJson.ref(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + DocumentReferenceQueryQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DocumentReferenceQueryDocumentSnapshot? startAtDocument, + DocumentReferenceQueryDocumentSnapshot? endAtDocument, + DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, + DocumentReferenceQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DocumentReferenceQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + DocumentReferenceQueryQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DocumentReferenceQueryDocumentSnapshot? startAtDocument, + DocumentReferenceQueryDocumentSnapshot? endAtDocument, + DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, + DocumentReferenceQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DocumentReferenceQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + DocumentReferenceQueryQuery orderByRef({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + DocumentReferenceQueryDocumentSnapshot? startAtDocument, + DocumentReferenceQueryDocumentSnapshot? endAtDocument, + DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, + DocumentReferenceQueryDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$DocumentReferenceQueryFieldMap['ref']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$DocumentReferenceQueryPerFieldToJson.ref( + startAt as DocumentReference>, + ), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$DocumentReferenceQueryPerFieldToJson.ref( + startAfter as DocumentReference>, + ), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$DocumentReferenceQueryPerFieldToJson.ref( + endAt as DocumentReference>, + ), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$DocumentReferenceQueryPerFieldToJson.ref( + endBefore as DocumentReference>, + ), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$DocumentReferenceQueryQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$DocumentReferenceQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class DocumentReferenceQueryDocumentSnapshot + extends FirestoreDocumentSnapshot { + DocumentReferenceQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + DocumentReferenceQueryDocumentReference get reference { + return DocumentReferenceQueryDocumentReference(snapshot.reference); + } + + @override + final DocumentReferenceQuery? data; +} + +class DocumentReferenceQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + DocumentReferenceQuery, + DocumentReferenceQueryQueryDocumentSnapshot + > { + DocumentReferenceQueryQuerySnapshot._( + this.snapshot, + this.docs, + this.docChanges, + ); + + factory DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(DocumentReferenceQueryQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + DocumentReferenceQueryDocumentSnapshot._, + ); + }).toList(); + + return DocumentReferenceQueryQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + DocumentReferenceQueryDocumentSnapshot Function(DocumentSnapshot doc) + decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> + docChanges; +} + +class DocumentReferenceQueryQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements DocumentReferenceQueryDocumentSnapshot { + DocumentReferenceQueryQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final DocumentReferenceQuery data; + + @override + DocumentReferenceQueryDocumentReference get reference { + return DocumentReferenceQueryDocumentReference(snapshot.reference); + } +} 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 be83670..e0b1e33 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/query.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/query.g.dart @@ -4,4715 +4,14 @@ part of 'query.dart'; -// ************************************************************************** -// CollectionGenerator -// ************************************************************************** - -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore -// ignore_for_file: type=lint -// ignore_for_file: invalid_use_of_internal_member - -class _Sentinel { - const _Sentinel(); -} - -const _sentinel = _Sentinel(); - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class DurationQueryCollectionReference - implements - DurationQueryQuery, - FirestoreCollectionReference { - factory DurationQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$DurationQueryCollectionReference; - - static DurationQuery fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$DurationQueryFromJson(snapshot.data()!); - } - - static Map toFirestore( - DurationQuery value, - SetOptions? options, - ) { - return _$DurationQueryToJson(value); - } - - @override - CollectionReference get reference; - - @override - DurationQueryDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(DurationQuery value); -} - -class _$DurationQueryCollectionReference extends _$DurationQueryQuery - implements DurationQueryCollectionReference { - factory _$DurationQueryCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$DurationQueryCollectionReference._( - firestore.collection('firestore-example-app/42/duration').withConverter( - fromFirestore: DurationQueryCollectionReference.fromFirestore, - toFirestore: DurationQueryCollectionReference.toFirestore, - ), - ); - } - - _$DurationQueryCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - DurationQueryDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return DurationQueryDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(DurationQuery value) { - return reference - .add(value) - .then((ref) => DurationQueryDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$DurationQueryCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class DurationQueryDocumentReference - extends FirestoreDocumentReference { - factory DurationQueryDocumentReference( - DocumentReference reference) = - _$DurationQueryDocumentReference; - - DocumentReference get reference; - - /// A reference to the [DurationQueryCollectionReference] containing this document. - DurationQueryCollectionReference get parent { - return _$DurationQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - DurationQuery model, { - SetOptions? options, - FieldValue durationFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - DurationQuery model, { - SetOptions? options, - FieldValue durationFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - DurationQuery model, { - SetOptions? options, - FieldValue durationFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - Duration duration, - FieldValue durationFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - DurationQuery, - DurationQueryDocumentSnapshot> implements DurationQueryDocumentReference { - _$DurationQueryDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [DurationQueryCollectionReference] containing this document. - DurationQueryCollectionReference get parent { - return _$DurationQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(DurationQueryDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(DurationQueryDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(DurationQueryDocumentSnapshot._); - } - - Future set( - DurationQuery model, { - SetOptions? options, - FieldValue? durationFieldValue, - }) async { - final json = { - ..._$DurationQueryToJson(model), - if (durationFieldValue != null) - _$DurationQueryFieldMap['duration']!: durationFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - DurationQuery model, { - SetOptions? options, - FieldValue? durationFieldValue, - }) { - final json = { - ..._$DurationQueryToJson(model), - if (durationFieldValue != null) - _$DurationQueryFieldMap['duration']!: durationFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - DurationQuery model, { - SetOptions? options, - FieldValue? durationFieldValue, - }) { - final json = { - ..._$DurationQueryToJson(model), - if (durationFieldValue != null) - _$DurationQueryFieldMap['duration']!: durationFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? duration = _sentinel, - FieldValue? durationFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class DurationQueryQuery - implements QueryReference { - @override - DurationQueryQuery limit(int limit); - - @override - DurationQueryQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - DurationQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - DurationQueryQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - DurationQueryQuery whereDuration({ - Duration? isEqualTo, - Duration? isNotEqualTo, - Duration? isLessThan, - Duration? isLessThanOrEqualTo, - Duration? isGreaterThan, - Duration? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - DurationQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - DurationQueryDocumentSnapshot? startAtDocument, - DurationQueryDocumentSnapshot? endAtDocument, - DurationQueryDocumentSnapshot? endBeforeDocument, - DurationQueryDocumentSnapshot? startAfterDocument, - }); - - DurationQueryQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - DurationQueryDocumentSnapshot? startAtDocument, - DurationQueryDocumentSnapshot? endAtDocument, - DurationQueryDocumentSnapshot? endBeforeDocument, - DurationQueryDocumentSnapshot? startAfterDocument, - }); - - DurationQueryQuery orderByDuration({ - bool descending = false, - Duration startAt, - Duration startAfter, - Duration endAt, - Duration endBefore, - DurationQueryDocumentSnapshot? startAtDocument, - DurationQueryDocumentSnapshot? endAtDocument, - DurationQueryDocumentSnapshot? endBeforeDocument, - DurationQueryDocumentSnapshot? startAfterDocument, - }); -} - -class _$DurationQueryQuery - extends QueryReference - implements DurationQueryQuery { - _$DurationQueryQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(DurationQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(DurationQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - DurationQueryQuery limit(int limit) { - return _$DurationQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - DurationQueryQuery limitToLast(int limit) { - return _$DurationQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - DurationQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$DurationQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DurationQueryQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$DurationQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DurationQueryQuery whereDuration({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$DurationQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$DurationQueryFieldMap['duration']!, - isEqualTo: isEqualTo != _sentinel - ? _$DurationQueryPerFieldToJson.duration(isEqualTo as Duration) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$DurationQueryPerFieldToJson.duration(isNotEqualTo as Duration) - : null, - isLessThan: isLessThan != null - ? _$DurationQueryPerFieldToJson.duration(isLessThan as Duration) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$DurationQueryPerFieldToJson - .duration(isLessThanOrEqualTo as Duration) - : null, - isGreaterThan: isGreaterThan != null - ? _$DurationQueryPerFieldToJson.duration(isGreaterThan as Duration) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DurationQueryPerFieldToJson - .duration(isGreaterThanOrEqualTo as Duration) - : null, - whereIn: whereIn?.map((e) => _$DurationQueryPerFieldToJson.duration(e)), - whereNotIn: - whereNotIn?.map((e) => _$DurationQueryPerFieldToJson.duration(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DurationQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DurationQueryDocumentSnapshot? startAtDocument, - DurationQueryDocumentSnapshot? endAtDocument, - DurationQueryDocumentSnapshot? endBeforeDocument, - DurationQueryDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DurationQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - DurationQueryQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DurationQueryDocumentSnapshot? startAtDocument, - DurationQueryDocumentSnapshot? endAtDocument, - DurationQueryDocumentSnapshot? endBeforeDocument, - DurationQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DurationQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - DurationQueryQuery orderByDuration({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DurationQueryDocumentSnapshot? startAtDocument, - DurationQueryDocumentSnapshot? endAtDocument, - DurationQueryDocumentSnapshot? endBeforeDocument, - DurationQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$DurationQueryFieldMap['duration']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DurationQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$DurationQueryQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class DurationQueryDocumentSnapshot - extends FirestoreDocumentSnapshot { - DurationQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - DurationQueryDocumentReference get reference { - return DurationQueryDocumentReference( - snapshot.reference, - ); - } - - @override - final DurationQuery? data; -} - -class DurationQueryQuerySnapshot extends FirestoreQuerySnapshot { - DurationQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory DurationQueryQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(DurationQueryQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - DurationQueryDocumentSnapshot._, - ); - }).toList(); - - return DurationQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - DurationQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class DurationQueryQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements DurationQueryDocumentSnapshot { - DurationQueryQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final DurationQuery data; - - @override - DurationQueryDocumentReference get reference { - return DurationQueryDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class DateTimeQueryCollectionReference - implements - DateTimeQueryQuery, - FirestoreCollectionReference { - factory DateTimeQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$DateTimeQueryCollectionReference; - - static DateTimeQuery fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$DateTimeQueryFromJson(snapshot.data()!); - } - - static Map toFirestore( - DateTimeQuery value, - SetOptions? options, - ) { - return _$DateTimeQueryToJson(value); - } - - @override - CollectionReference get reference; - - @override - DateTimeQueryDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(DateTimeQuery value); -} - -class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery - implements DateTimeQueryCollectionReference { - factory _$DateTimeQueryCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$DateTimeQueryCollectionReference._( - firestore.collection('firestore-example-app/42/date-time').withConverter( - fromFirestore: DateTimeQueryCollectionReference.fromFirestore, - toFirestore: DateTimeQueryCollectionReference.toFirestore, - ), - ); - } - - _$DateTimeQueryCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - DateTimeQueryDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return DateTimeQueryDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(DateTimeQuery value) { - return reference - .add(value) - .then((ref) => DateTimeQueryDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$DateTimeQueryCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class DateTimeQueryDocumentReference - extends FirestoreDocumentReference { - factory DateTimeQueryDocumentReference( - DocumentReference reference) = - _$DateTimeQueryDocumentReference; - - DocumentReference get reference; - - /// A reference to the [DateTimeQueryCollectionReference] containing this document. - DateTimeQueryCollectionReference get parent { - return _$DateTimeQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - DateTimeQuery model, { - SetOptions? options, - FieldValue timeFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - DateTimeQuery model, { - SetOptions? options, - FieldValue timeFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - DateTimeQuery model, { - SetOptions? options, - FieldValue timeFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - DateTime time, - FieldValue timeFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - DateTimeQuery, - DateTimeQueryDocumentSnapshot> implements DateTimeQueryDocumentReference { - _$DateTimeQueryDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [DateTimeQueryCollectionReference] containing this document. - DateTimeQueryCollectionReference get parent { - return _$DateTimeQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(DateTimeQueryDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(DateTimeQueryDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(DateTimeQueryDocumentSnapshot._); - } - - Future set( - DateTimeQuery model, { - SetOptions? options, - FieldValue? timeFieldValue, - }) async { - final json = { - ..._$DateTimeQueryToJson(model), - if (timeFieldValue != null) - _$DateTimeQueryFieldMap['time']!: timeFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - DateTimeQuery model, { - SetOptions? options, - FieldValue? timeFieldValue, - }) { - final json = { - ..._$DateTimeQueryToJson(model), - if (timeFieldValue != null) - _$DateTimeQueryFieldMap['time']!: timeFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - DateTimeQuery model, { - SetOptions? options, - FieldValue? timeFieldValue, - }) { - final json = { - ..._$DateTimeQueryToJson(model), - if (timeFieldValue != null) - _$DateTimeQueryFieldMap['time']!: timeFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? time = _sentinel, - FieldValue? timeFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class DateTimeQueryQuery - implements QueryReference { - @override - DateTimeQueryQuery limit(int limit); - - @override - DateTimeQueryQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - DateTimeQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - DateTimeQueryQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - DateTimeQueryQuery whereTime({ - DateTime? isEqualTo, - DateTime? isNotEqualTo, - DateTime? isLessThan, - DateTime? isLessThanOrEqualTo, - DateTime? isGreaterThan, - DateTime? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - DateTimeQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - DateTimeQueryDocumentSnapshot? startAtDocument, - DateTimeQueryDocumentSnapshot? endAtDocument, - DateTimeQueryDocumentSnapshot? endBeforeDocument, - DateTimeQueryDocumentSnapshot? startAfterDocument, - }); - - DateTimeQueryQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - DateTimeQueryDocumentSnapshot? startAtDocument, - DateTimeQueryDocumentSnapshot? endAtDocument, - DateTimeQueryDocumentSnapshot? endBeforeDocument, - DateTimeQueryDocumentSnapshot? startAfterDocument, - }); - - DateTimeQueryQuery orderByTime({ - bool descending = false, - DateTime startAt, - DateTime startAfter, - DateTime endAt, - DateTime endBefore, - DateTimeQueryDocumentSnapshot? startAtDocument, - DateTimeQueryDocumentSnapshot? endAtDocument, - DateTimeQueryDocumentSnapshot? endBeforeDocument, - DateTimeQueryDocumentSnapshot? startAfterDocument, - }); -} - -class _$DateTimeQueryQuery - extends QueryReference - implements DateTimeQueryQuery { - _$DateTimeQueryQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(DateTimeQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(DateTimeQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - DateTimeQueryQuery limit(int limit) { - return _$DateTimeQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - DateTimeQueryQuery limitToLast(int limit) { - return _$DateTimeQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - DateTimeQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$DateTimeQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DateTimeQueryQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$DateTimeQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DateTimeQueryQuery whereTime({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$DateTimeQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$DateTimeQueryFieldMap['time']!, - isEqualTo: isEqualTo != _sentinel - ? _$DateTimeQueryPerFieldToJson.time(isEqualTo as DateTime) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$DateTimeQueryPerFieldToJson.time(isNotEqualTo as DateTime) - : null, - isLessThan: isLessThan != null - ? _$DateTimeQueryPerFieldToJson.time(isLessThan as DateTime) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$DateTimeQueryPerFieldToJson - .time(isLessThanOrEqualTo as DateTime) - : null, - isGreaterThan: isGreaterThan != null - ? _$DateTimeQueryPerFieldToJson.time(isGreaterThan as DateTime) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DateTimeQueryPerFieldToJson - .time(isGreaterThanOrEqualTo as DateTime) - : null, - whereIn: whereIn?.map((e) => _$DateTimeQueryPerFieldToJson.time(e)), - whereNotIn: - whereNotIn?.map((e) => _$DateTimeQueryPerFieldToJson.time(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DateTimeQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DateTimeQueryDocumentSnapshot? startAtDocument, - DateTimeQueryDocumentSnapshot? endAtDocument, - DateTimeQueryDocumentSnapshot? endBeforeDocument, - DateTimeQueryDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DateTimeQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - DateTimeQueryQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DateTimeQueryDocumentSnapshot? startAtDocument, - DateTimeQueryDocumentSnapshot? endAtDocument, - DateTimeQueryDocumentSnapshot? endBeforeDocument, - DateTimeQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DateTimeQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - DateTimeQueryQuery orderByTime({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DateTimeQueryDocumentSnapshot? startAtDocument, - DateTimeQueryDocumentSnapshot? endAtDocument, - DateTimeQueryDocumentSnapshot? endBeforeDocument, - DateTimeQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$DateTimeQueryFieldMap['time']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DateTimeQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$DateTimeQueryQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class DateTimeQueryDocumentSnapshot - extends FirestoreDocumentSnapshot { - DateTimeQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - DateTimeQueryDocumentReference get reference { - return DateTimeQueryDocumentReference( - snapshot.reference, - ); - } - - @override - final DateTimeQuery? data; -} - -class DateTimeQueryQuerySnapshot extends FirestoreQuerySnapshot { - DateTimeQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory DateTimeQueryQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(DateTimeQueryQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - DateTimeQueryDocumentSnapshot._, - ); - }).toList(); - - return DateTimeQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - DateTimeQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class DateTimeQueryQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements DateTimeQueryDocumentSnapshot { - DateTimeQueryQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final DateTimeQuery data; - - @override - DateTimeQueryDocumentReference get reference { - return DateTimeQueryDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class TimestampQueryCollectionReference - implements - TimestampQueryQuery, - FirestoreCollectionReference { - factory TimestampQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$TimestampQueryCollectionReference; - - static TimestampQuery fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$TimestampQueryFromJson(snapshot.data()!); - } - - static Map toFirestore( - TimestampQuery value, - SetOptions? options, - ) { - return _$TimestampQueryToJson(value); - } - - @override - CollectionReference get reference; - - @override - TimestampQueryDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(TimestampQuery value); -} - -class _$TimestampQueryCollectionReference extends _$TimestampQueryQuery - implements TimestampQueryCollectionReference { - factory _$TimestampQueryCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$TimestampQueryCollectionReference._( - firestore - .collection('firestore-example-app/42/timestamp-time') - .withConverter( - fromFirestore: TimestampQueryCollectionReference.fromFirestore, - toFirestore: TimestampQueryCollectionReference.toFirestore, - ), - ); - } - - _$TimestampQueryCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - TimestampQueryDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return TimestampQueryDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(TimestampQuery value) { - return reference - .add(value) - .then((ref) => TimestampQueryDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$TimestampQueryCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class TimestampQueryDocumentReference - extends FirestoreDocumentReference { - factory TimestampQueryDocumentReference( - DocumentReference reference) = - _$TimestampQueryDocumentReference; - - DocumentReference get reference; - - /// A reference to the [TimestampQueryCollectionReference] containing this document. - TimestampQueryCollectionReference get parent { - return _$TimestampQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - TimestampQuery model, { - SetOptions? options, - FieldValue timeFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - TimestampQuery model, { - SetOptions? options, - FieldValue timeFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - TimestampQuery model, { - SetOptions? options, - FieldValue timeFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - Timestamp time, - FieldValue timeFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - TimestampQuery, - TimestampQueryDocumentSnapshot> implements TimestampQueryDocumentReference { - _$TimestampQueryDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [TimestampQueryCollectionReference] containing this document. - TimestampQueryCollectionReference get parent { - return _$TimestampQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(TimestampQueryDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(TimestampQueryDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(TimestampQueryDocumentSnapshot._); - } - - Future set( - TimestampQuery model, { - SetOptions? options, - FieldValue? timeFieldValue, - }) async { - final json = { - ..._$TimestampQueryToJson(model), - if (timeFieldValue != null) - _$TimestampQueryFieldMap['time']!: timeFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - TimestampQuery model, { - SetOptions? options, - FieldValue? timeFieldValue, - }) { - final json = { - ..._$TimestampQueryToJson(model), - if (timeFieldValue != null) - _$TimestampQueryFieldMap['time']!: timeFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - TimestampQuery model, { - SetOptions? options, - FieldValue? timeFieldValue, - }) { - final json = { - ..._$TimestampQueryToJson(model), - if (timeFieldValue != null) - _$TimestampQueryFieldMap['time']!: timeFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? time = _sentinel, - FieldValue? timeFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class TimestampQueryQuery - implements QueryReference { - @override - TimestampQueryQuery limit(int limit); - - @override - TimestampQueryQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - TimestampQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - TimestampQueryQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - TimestampQueryQuery whereTime({ - Timestamp? isEqualTo, - Timestamp? isNotEqualTo, - Timestamp? isLessThan, - Timestamp? isLessThanOrEqualTo, - Timestamp? isGreaterThan, - Timestamp? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - TimestampQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - TimestampQueryDocumentSnapshot? startAtDocument, - TimestampQueryDocumentSnapshot? endAtDocument, - TimestampQueryDocumentSnapshot? endBeforeDocument, - TimestampQueryDocumentSnapshot? startAfterDocument, - }); - - TimestampQueryQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - TimestampQueryDocumentSnapshot? startAtDocument, - TimestampQueryDocumentSnapshot? endAtDocument, - TimestampQueryDocumentSnapshot? endBeforeDocument, - TimestampQueryDocumentSnapshot? startAfterDocument, - }); - - TimestampQueryQuery orderByTime({ - bool descending = false, - Timestamp startAt, - Timestamp startAfter, - Timestamp endAt, - Timestamp endBefore, - TimestampQueryDocumentSnapshot? startAtDocument, - TimestampQueryDocumentSnapshot? endAtDocument, - TimestampQueryDocumentSnapshot? endBeforeDocument, - TimestampQueryDocumentSnapshot? startAfterDocument, - }); -} - -class _$TimestampQueryQuery - extends QueryReference - implements TimestampQueryQuery { - _$TimestampQueryQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(TimestampQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(TimestampQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - TimestampQueryQuery limit(int limit) { - return _$TimestampQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - TimestampQueryQuery limitToLast(int limit) { - return _$TimestampQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - TimestampQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$TimestampQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - TimestampQueryQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$TimestampQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - TimestampQueryQuery whereTime({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$TimestampQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$TimestampQueryFieldMap['time']!, - isEqualTo: isEqualTo != _sentinel - ? _$TimestampQueryPerFieldToJson.time(isEqualTo as Timestamp) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$TimestampQueryPerFieldToJson.time(isNotEqualTo as Timestamp) - : null, - isLessThan: isLessThan != null - ? _$TimestampQueryPerFieldToJson.time(isLessThan as Timestamp) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$TimestampQueryPerFieldToJson - .time(isLessThanOrEqualTo as Timestamp) - : null, - isGreaterThan: isGreaterThan != null - ? _$TimestampQueryPerFieldToJson.time(isGreaterThan as Timestamp) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$TimestampQueryPerFieldToJson - .time(isGreaterThanOrEqualTo as Timestamp) - : null, - whereIn: whereIn?.map((e) => _$TimestampQueryPerFieldToJson.time(e)), - whereNotIn: - whereNotIn?.map((e) => _$TimestampQueryPerFieldToJson.time(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - TimestampQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - TimestampQueryDocumentSnapshot? startAtDocument, - TimestampQueryDocumentSnapshot? endAtDocument, - TimestampQueryDocumentSnapshot? endBeforeDocument, - TimestampQueryDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$TimestampQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - TimestampQueryQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - TimestampQueryDocumentSnapshot? startAtDocument, - TimestampQueryDocumentSnapshot? endAtDocument, - TimestampQueryDocumentSnapshot? endBeforeDocument, - TimestampQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$TimestampQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - TimestampQueryQuery orderByTime({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - TimestampQueryDocumentSnapshot? startAtDocument, - TimestampQueryDocumentSnapshot? endAtDocument, - TimestampQueryDocumentSnapshot? endBeforeDocument, - TimestampQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$TimestampQueryFieldMap['time']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$TimestampQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$TimestampQueryQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class TimestampQueryDocumentSnapshot - extends FirestoreDocumentSnapshot { - TimestampQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - TimestampQueryDocumentReference get reference { - return TimestampQueryDocumentReference( - snapshot.reference, - ); - } - - @override - final TimestampQuery? data; -} - -class TimestampQueryQuerySnapshot extends FirestoreQuerySnapshot { - TimestampQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory TimestampQueryQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(TimestampQueryQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - TimestampQueryDocumentSnapshot._, - ); - }).toList(); - - return TimestampQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - TimestampQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> - docChanges; -} - -class TimestampQueryQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements TimestampQueryDocumentSnapshot { - TimestampQueryQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final TimestampQuery data; - - @override - TimestampQueryDocumentReference get reference { - return TimestampQueryDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class GeoPointQueryCollectionReference - implements - GeoPointQueryQuery, - FirestoreCollectionReference { - factory GeoPointQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$GeoPointQueryCollectionReference; - - static GeoPointQuery fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$GeoPointQueryFromJson(snapshot.data()!); - } - - static Map toFirestore( - GeoPointQuery value, - SetOptions? options, - ) { - return _$GeoPointQueryToJson(value); - } - - @override - CollectionReference get reference; - - @override - GeoPointQueryDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(GeoPointQuery value); -} - -class _$GeoPointQueryCollectionReference extends _$GeoPointQueryQuery - implements GeoPointQueryCollectionReference { - factory _$GeoPointQueryCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$GeoPointQueryCollectionReference._( - firestore - .collection('firestore-example-app/42/geopoint-time') - .withConverter( - fromFirestore: GeoPointQueryCollectionReference.fromFirestore, - toFirestore: GeoPointQueryCollectionReference.toFirestore, - ), - ); - } - - _$GeoPointQueryCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - GeoPointQueryDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return GeoPointQueryDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(GeoPointQuery value) { - return reference - .add(value) - .then((ref) => GeoPointQueryDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$GeoPointQueryCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class GeoPointQueryDocumentReference - extends FirestoreDocumentReference { - factory GeoPointQueryDocumentReference( - DocumentReference reference) = - _$GeoPointQueryDocumentReference; - - DocumentReference get reference; - - /// A reference to the [GeoPointQueryCollectionReference] containing this document. - GeoPointQueryCollectionReference get parent { - return _$GeoPointQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - GeoPointQuery model, { - SetOptions? options, - FieldValue pointFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - GeoPointQuery model, { - SetOptions? options, - FieldValue pointFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - GeoPointQuery model, { - SetOptions? options, - FieldValue pointFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - GeoPoint point, - FieldValue pointFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - GeoPointQuery, - GeoPointQueryDocumentSnapshot> implements GeoPointQueryDocumentReference { - _$GeoPointQueryDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [GeoPointQueryCollectionReference] containing this document. - GeoPointQueryCollectionReference get parent { - return _$GeoPointQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(GeoPointQueryDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(GeoPointQueryDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(GeoPointQueryDocumentSnapshot._); - } - - Future set( - GeoPointQuery model, { - SetOptions? options, - FieldValue? pointFieldValue, - }) async { - final json = { - ..._$GeoPointQueryToJson(model), - if (pointFieldValue != null) - _$GeoPointQueryFieldMap['point']!: pointFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - GeoPointQuery model, { - SetOptions? options, - FieldValue? pointFieldValue, - }) { - final json = { - ..._$GeoPointQueryToJson(model), - if (pointFieldValue != null) - _$GeoPointQueryFieldMap['point']!: pointFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - GeoPointQuery model, { - SetOptions? options, - FieldValue? pointFieldValue, - }) { - final json = { - ..._$GeoPointQueryToJson(model), - if (pointFieldValue != null) - _$GeoPointQueryFieldMap['point']!: pointFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? point = _sentinel, - FieldValue? pointFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class GeoPointQueryQuery - implements QueryReference { - @override - GeoPointQueryQuery limit(int limit); - - @override - GeoPointQueryQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - GeoPointQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - GeoPointQueryQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - GeoPointQueryQuery wherePoint({ - GeoPoint? isEqualTo, - GeoPoint? isNotEqualTo, - GeoPoint? isLessThan, - GeoPoint? isLessThanOrEqualTo, - GeoPoint? isGreaterThan, - GeoPoint? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - GeoPointQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - GeoPointQueryDocumentSnapshot? startAtDocument, - GeoPointQueryDocumentSnapshot? endAtDocument, - GeoPointQueryDocumentSnapshot? endBeforeDocument, - GeoPointQueryDocumentSnapshot? startAfterDocument, - }); - - GeoPointQueryQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - GeoPointQueryDocumentSnapshot? startAtDocument, - GeoPointQueryDocumentSnapshot? endAtDocument, - GeoPointQueryDocumentSnapshot? endBeforeDocument, - GeoPointQueryDocumentSnapshot? startAfterDocument, - }); - - GeoPointQueryQuery orderByPoint({ - bool descending = false, - GeoPoint startAt, - GeoPoint startAfter, - GeoPoint endAt, - GeoPoint endBefore, - GeoPointQueryDocumentSnapshot? startAtDocument, - GeoPointQueryDocumentSnapshot? endAtDocument, - GeoPointQueryDocumentSnapshot? endBeforeDocument, - GeoPointQueryDocumentSnapshot? startAfterDocument, - }); -} - -class _$GeoPointQueryQuery - extends QueryReference - implements GeoPointQueryQuery { - _$GeoPointQueryQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(GeoPointQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(GeoPointQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - GeoPointQueryQuery limit(int limit) { - return _$GeoPointQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - GeoPointQueryQuery limitToLast(int limit) { - return _$GeoPointQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - GeoPointQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$GeoPointQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - GeoPointQueryQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$GeoPointQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - GeoPointQueryQuery wherePoint({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$GeoPointQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$GeoPointQueryFieldMap['point']!, - isEqualTo: isEqualTo != _sentinel - ? _$GeoPointQueryPerFieldToJson.point(isEqualTo as GeoPoint) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$GeoPointQueryPerFieldToJson.point(isNotEqualTo as GeoPoint) - : null, - isLessThan: isLessThan != null - ? _$GeoPointQueryPerFieldToJson.point(isLessThan as GeoPoint) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$GeoPointQueryPerFieldToJson - .point(isLessThanOrEqualTo as GeoPoint) - : null, - isGreaterThan: isGreaterThan != null - ? _$GeoPointQueryPerFieldToJson.point(isGreaterThan as GeoPoint) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$GeoPointQueryPerFieldToJson - .point(isGreaterThanOrEqualTo as GeoPoint) - : null, - whereIn: whereIn?.map((e) => _$GeoPointQueryPerFieldToJson.point(e)), - whereNotIn: - whereNotIn?.map((e) => _$GeoPointQueryPerFieldToJson.point(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - GeoPointQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - GeoPointQueryDocumentSnapshot? startAtDocument, - GeoPointQueryDocumentSnapshot? endAtDocument, - GeoPointQueryDocumentSnapshot? endBeforeDocument, - GeoPointQueryDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$GeoPointQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - GeoPointQueryQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - GeoPointQueryDocumentSnapshot? startAtDocument, - GeoPointQueryDocumentSnapshot? endAtDocument, - GeoPointQueryDocumentSnapshot? endBeforeDocument, - GeoPointQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$GeoPointQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - GeoPointQueryQuery orderByPoint({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - GeoPointQueryDocumentSnapshot? startAtDocument, - GeoPointQueryDocumentSnapshot? endAtDocument, - GeoPointQueryDocumentSnapshot? endBeforeDocument, - GeoPointQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$GeoPointQueryFieldMap['point']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$GeoPointQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$GeoPointQueryQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class GeoPointQueryDocumentSnapshot - extends FirestoreDocumentSnapshot { - GeoPointQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - GeoPointQueryDocumentReference get reference { - return GeoPointQueryDocumentReference( - snapshot.reference, - ); - } - - @override - final GeoPointQuery? data; -} - -class GeoPointQueryQuerySnapshot extends FirestoreQuerySnapshot { - GeoPointQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory GeoPointQueryQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(GeoPointQueryQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - GeoPointQueryDocumentSnapshot._, - ); - }).toList(); - - return GeoPointQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - GeoPointQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class GeoPointQueryQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements GeoPointQueryDocumentSnapshot { - GeoPointQueryQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final GeoPointQuery data; - - @override - GeoPointQueryDocumentReference get reference { - return GeoPointQueryDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class DocumentReferenceQueryCollectionReference - implements - DocumentReferenceQueryQuery, - FirestoreCollectionReference { - factory DocumentReferenceQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$DocumentReferenceQueryCollectionReference; - - static DocumentReferenceQuery fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$DocumentReferenceQueryFromJson(snapshot.data()!); - } - - static Map toFirestore( - DocumentReferenceQuery value, - SetOptions? options, - ) { - return _$DocumentReferenceQueryToJson(value); - } - - @override - CollectionReference get reference; - - @override - DocumentReferenceQueryDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add( - DocumentReferenceQuery value); -} - -class _$DocumentReferenceQueryCollectionReference - extends _$DocumentReferenceQueryQuery - implements DocumentReferenceQueryCollectionReference { - factory _$DocumentReferenceQueryCollectionReference( - [FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$DocumentReferenceQueryCollectionReference._( - firestore.collection('firestore-example-app/42/doc-ref').withConverter( - fromFirestore: - DocumentReferenceQueryCollectionReference.fromFirestore, - toFirestore: DocumentReferenceQueryCollectionReference.toFirestore, - ), - ); - } - - _$DocumentReferenceQueryCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - DocumentReferenceQueryDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return DocumentReferenceQueryDocumentReference( - reference.doc(id), - ); - } - - @override - Future add( - DocumentReferenceQuery value) { - return reference - .add(value) - .then((ref) => DocumentReferenceQueryDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$DocumentReferenceQueryCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class DocumentReferenceQueryDocumentReference - extends FirestoreDocumentReference { - factory DocumentReferenceQueryDocumentReference( - DocumentReference reference) = - _$DocumentReferenceQueryDocumentReference; - - DocumentReference get reference; - - /// A reference to the [DocumentReferenceQueryCollectionReference] containing this document. - DocumentReferenceQueryCollectionReference get parent { - return _$DocumentReferenceQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - DocumentReferenceQuery model, { - SetOptions? options, - FieldValue refFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - DocumentReferenceQuery model, { - SetOptions? options, - FieldValue refFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - DocumentReferenceQuery model, { - SetOptions? options, - FieldValue refFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - DocumentReference> ref, - FieldValue refFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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 - extends FirestoreDocumentReference - implements DocumentReferenceQueryDocumentReference { - _$DocumentReferenceQueryDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [DocumentReferenceQueryCollectionReference] containing this document. - DocumentReferenceQueryCollectionReference get parent { - return _$DocumentReferenceQueryCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(DocumentReferenceQueryDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(DocumentReferenceQueryDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction - .get(reference) - .then(DocumentReferenceQueryDocumentSnapshot._); - } - - Future set( - DocumentReferenceQuery model, { - SetOptions? options, - FieldValue? refFieldValue, - }) async { - final json = { - ..._$DocumentReferenceQueryToJson(model), - if (refFieldValue != null) - _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - DocumentReferenceQuery model, { - SetOptions? options, - FieldValue? refFieldValue, - }) { - final json = { - ..._$DocumentReferenceQueryToJson(model), - if (refFieldValue != null) - _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - DocumentReferenceQuery model, { - SetOptions? options, - FieldValue? refFieldValue, - }) { - final json = { - ..._$DocumentReferenceQueryToJson(model), - if (refFieldValue != null) - _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? ref = _sentinel, - FieldValue? refFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class DocumentReferenceQueryQuery - implements - QueryReference { - @override - DocumentReferenceQueryQuery limit(int limit); - - @override - DocumentReferenceQueryQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - DocumentReferenceQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - DocumentReferenceQueryQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - DocumentReferenceQueryQuery whereRef({ - DocumentReference>? isEqualTo, - DocumentReference>? isNotEqualTo, - DocumentReference>? isLessThan, - DocumentReference>? isLessThanOrEqualTo, - DocumentReference>? isGreaterThan, - DocumentReference>? isGreaterThanOrEqualTo, - List>>? whereIn, - List>>? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - DocumentReferenceQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - DocumentReferenceQueryDocumentSnapshot? startAtDocument, - DocumentReferenceQueryDocumentSnapshot? endAtDocument, - DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, - DocumentReferenceQueryDocumentSnapshot? startAfterDocument, - }); - - DocumentReferenceQueryQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - DocumentReferenceQueryDocumentSnapshot? startAtDocument, - DocumentReferenceQueryDocumentSnapshot? endAtDocument, - DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, - DocumentReferenceQueryDocumentSnapshot? startAfterDocument, - }); - - DocumentReferenceQueryQuery orderByRef({ - bool descending = false, - DocumentReference> startAt, - DocumentReference> startAfter, - DocumentReference> endAt, - DocumentReference> endBefore, - DocumentReferenceQueryDocumentSnapshot? startAtDocument, - DocumentReferenceQueryDocumentSnapshot? endAtDocument, - DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, - DocumentReferenceQueryDocumentSnapshot? startAfterDocument, - }); -} - -class _$DocumentReferenceQueryQuery extends QueryReference< - DocumentReferenceQuery, DocumentReferenceQueryQuerySnapshot> - implements DocumentReferenceQueryQuery { - _$DocumentReferenceQueryQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot); - } - - @override - DocumentReferenceQueryQuery limit(int limit) { - return _$DocumentReferenceQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - DocumentReferenceQueryQuery limitToLast(int limit) { - return _$DocumentReferenceQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - DocumentReferenceQueryQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$DocumentReferenceQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DocumentReferenceQueryQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$DocumentReferenceQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DocumentReferenceQueryQuery whereRef({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List>>? whereIn, - List>>? whereNotIn, - bool? isNull, - }) { - return _$DocumentReferenceQueryQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$DocumentReferenceQueryFieldMap['ref']!, - isEqualTo: isEqualTo != _sentinel - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isEqualTo as DocumentReference>) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isNotEqualTo as DocumentReference>) - : null, - isLessThan: isLessThan != null - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isLessThan as DocumentReference>) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$DocumentReferenceQueryPerFieldToJson.ref( - isLessThanOrEqualTo as DocumentReference>) - : null, - isGreaterThan: isGreaterThan != null - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isGreaterThan as DocumentReference>) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DocumentReferenceQueryPerFieldToJson.ref(isGreaterThanOrEqualTo - as DocumentReference>) - : null, - whereIn: - whereIn?.map((e) => _$DocumentReferenceQueryPerFieldToJson.ref(e)), - whereNotIn: whereNotIn - ?.map((e) => _$DocumentReferenceQueryPerFieldToJson.ref(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - DocumentReferenceQueryQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DocumentReferenceQueryDocumentSnapshot? startAtDocument, - DocumentReferenceQueryDocumentSnapshot? endAtDocument, - DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, - DocumentReferenceQueryDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DocumentReferenceQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - DocumentReferenceQueryQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DocumentReferenceQueryDocumentSnapshot? startAtDocument, - DocumentReferenceQueryDocumentSnapshot? endAtDocument, - DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, - DocumentReferenceQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DocumentReferenceQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - DocumentReferenceQueryQuery orderByRef({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - DocumentReferenceQueryDocumentSnapshot? startAtDocument, - DocumentReferenceQueryDocumentSnapshot? endAtDocument, - DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, - DocumentReferenceQueryDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy( - _$DocumentReferenceQueryFieldMap['ref']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$DocumentReferenceQueryQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$DocumentReferenceQueryQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class DocumentReferenceQueryDocumentSnapshot - extends FirestoreDocumentSnapshot { - DocumentReferenceQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - DocumentReferenceQueryDocumentReference get reference { - return DocumentReferenceQueryDocumentReference( - snapshot.reference, - ); - } - - @override - final DocumentReferenceQuery? data; -} - -class DocumentReferenceQueryQuerySnapshot extends FirestoreQuerySnapshot< - DocumentReferenceQuery, DocumentReferenceQueryQueryDocumentSnapshot> { - DocumentReferenceQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs - .map(DocumentReferenceQueryQueryDocumentSnapshot._) - .toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - DocumentReferenceQueryDocumentSnapshot._, - ); - }).toList(); - - return DocumentReferenceQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - DocumentReferenceQueryDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> - docChanges; -} - -class DocumentReferenceQueryQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements DocumentReferenceQueryDocumentSnapshot { - DocumentReferenceQueryQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final DocumentReferenceQuery data; - - @override - DocumentReferenceQueryDocumentReference get reference { - return DocumentReferenceQueryDocumentReference(snapshot.reference); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** DurationQuery _$DurationQueryFromJson(Map json) => - DurationQuery( - Duration(microseconds: (json['duration'] as num).toInt()), - ); + DurationQuery(Duration(microseconds: (json['duration'] as num).toInt())); -const _$DurationQueryFieldMap = { - 'duration': 'duration', -}; +const _$DurationQueryFieldMap = {'duration': 'duration'}; // ignore: unused_element abstract class _$DurationQueryPerFieldToJson { @@ -4721,18 +20,14 @@ abstract class _$DurationQueryPerFieldToJson { } Map _$DurationQueryToJson(DurationQuery instance) => - { - 'duration': instance.duration.inMicroseconds, - }; + {'duration': instance.duration.inMicroseconds}; DateTimeQuery _$DateTimeQueryFromJson(Map json) => DateTimeQuery( const FirestoreDateTimeConverter().fromJson(json['time'] as Timestamp), ); -const _$DateTimeQueryFieldMap = { - 'time': 'time', -}; +const _$DateTimeQueryFieldMap = {'time': 'time'}; // ignore: unused_element abstract class _$DateTimeQueryPerFieldToJson { @@ -4751,9 +46,7 @@ TimestampQuery _$TimestampQueryFromJson(Map json) => const FirestoreTimestampConverter().fromJson(json['time'] as Timestamp), ); -const _$TimestampQueryFieldMap = { - 'time': 'time', -}; +const _$TimestampQueryFieldMap = {'time': 'time'}; // ignore: unused_element abstract class _$TimestampQueryPerFieldToJson { @@ -4772,9 +65,7 @@ GeoPointQuery _$GeoPointQueryFromJson(Map json) => const FirestoreGeoPointConverter().fromJson(json['point'] as GeoPoint), ); -const _$GeoPointQueryFieldMap = { - 'point': 'point', -}; +const _$GeoPointQueryFieldMap = {'point': 'point'}; // ignore: unused_element abstract class _$GeoPointQueryPerFieldToJson { @@ -4789,15 +80,14 @@ Map _$GeoPointQueryToJson(GeoPointQuery instance) => }; DocumentReferenceQuery _$DocumentReferenceQueryFromJson( - Map json) => - DocumentReferenceQuery( - const FirestoreDocumentReferenceConverter() - .fromJson(json['ref'] as DocumentReference>), - ); + Map json, +) => DocumentReferenceQuery( + const FirestoreDocumentReferenceConverter().fromJson( + json['ref'] as DocumentReference>, + ), +); -const _$DocumentReferenceQueryFieldMap = { - 'ref': 'ref', -}; +const _$DocumentReferenceQueryFieldMap = {'ref': 'ref'}; // ignore: unused_element abstract class _$DocumentReferenceQueryPerFieldToJson { @@ -4807,7 +97,7 @@ abstract class _$DocumentReferenceQueryPerFieldToJson { } Map _$DocumentReferenceQueryToJson( - DocumentReferenceQuery instance) => - { - 'ref': const FirestoreDocumentReferenceConverter().toJson(instance.ref), - }; + DocumentReferenceQuery instance, +) => { + 'ref': const FirestoreDocumentReferenceConverter().toJson(instance.ref), +}; diff --git a/packages/cloud_firestore_odm/example/lib/movie.dart b/packages/cloud_firestore_odm/example/lib/movie.dart index d0d8044..a0d2aa0 100644 --- a/packages/cloud_firestore_odm/example/lib/movie.dart +++ b/packages/cloud_firestore_odm/example/lib/movie.dart @@ -6,6 +6,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:json_annotation/json_annotation.dart'; +part 'movie.firebase.dart'; part 'movie.g.dart'; @JsonSerializable() @@ -44,10 +45,7 @@ final moviesRef = MovieCollectionReference(); @JsonSerializable() class Comment { - Comment({ - required this.authorName, - required this.message, - }); + Comment({required this.authorName, required this.message}); final String authorName; final String message; diff --git a/packages/cloud_firestore_odm/example/lib/movie.firebase.dart b/packages/cloud_firestore_odm/example/lib/movie.firebase.dart new file mode 100644 index 0000000..b15fb0d --- /dev/null +++ b/packages/cloud_firestore_odm/example/lib/movie.firebase.dart @@ -0,0 +1,3616 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'movie.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class MovieCollectionReference + implements + MovieQuery, + FirestoreCollectionReference { + factory MovieCollectionReference([FirebaseFirestore? firestore]) = + _$MovieCollectionReference; + + static Movie fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$MovieFromJson({'id': snapshot.id, ...?snapshot.data()}); + } + + static Map toFirestore(Movie value, SetOptions? options) { + return {..._$MovieToJson(value)}..remove('id'); + } + + @override + CollectionReference get reference; + + @override + MovieDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Movie value); +} + +class _$MovieCollectionReference extends _$MovieQuery + implements MovieCollectionReference { + factory _$MovieCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$MovieCollectionReference._( + firestore + .collection('firestore-example-app') + .withConverter( + fromFirestore: MovieCollectionReference.fromFirestore, + toFirestore: MovieCollectionReference.toFirestore, + ), + ); + } + + _$MovieCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + MovieDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return MovieDocumentReference(reference.doc(id)); + } + + @override + Future add(Movie value) { + return reference.add(value).then((ref) => MovieDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$MovieCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class MovieDocumentReference + extends FirestoreDocumentReference { + factory MovieDocumentReference(DocumentReference reference) = + _$MovieDocumentReference; + + DocumentReference get reference; + + /// A reference to the [MovieCollectionReference] containing this document. + MovieCollectionReference get parent { + return _$MovieCollectionReference(reference.firestore); + } + + late final CommentCollectionReference comments = _$CommentCollectionReference( + reference, + ); + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Movie model, { + SetOptions? options, + FieldValue posterFieldValue, + FieldValue likesFieldValue, + FieldValue titleFieldValue, + FieldValue yearFieldValue, + FieldValue runtimeFieldValue, + FieldValue ratedFieldValue, + FieldValue genreFieldValue, + FieldValue tagsFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Movie model, { + SetOptions? options, + FieldValue posterFieldValue, + FieldValue likesFieldValue, + FieldValue titleFieldValue, + FieldValue yearFieldValue, + FieldValue runtimeFieldValue, + FieldValue ratedFieldValue, + FieldValue genreFieldValue, + FieldValue tagsFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Movie model, { + SetOptions? options, + FieldValue posterFieldValue, + FieldValue likesFieldValue, + FieldValue titleFieldValue, + FieldValue yearFieldValue, + FieldValue runtimeFieldValue, + FieldValue ratedFieldValue, + FieldValue genreFieldValue, + FieldValue tagsFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + 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, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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, + }); + + /// 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 + extends FirestoreDocumentReference + implements MovieDocumentReference { + _$MovieDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [MovieCollectionReference] containing this document. + MovieCollectionReference get parent { + return _$MovieCollectionReference(reference.firestore); + } + + late final CommentCollectionReference comments = _$CommentCollectionReference( + reference, + ); + + @override + Stream snapshots() { + return reference.snapshots().map(MovieDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(MovieDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(MovieDocumentSnapshot._); + } + + Future set( + Movie model, { + SetOptions? options, + FieldValue? posterFieldValue, + FieldValue? likesFieldValue, + FieldValue? titleFieldValue, + FieldValue? yearFieldValue, + FieldValue? runtimeFieldValue, + FieldValue? ratedFieldValue, + FieldValue? genreFieldValue, + FieldValue? tagsFieldValue, + }) async { + final json = { + ..._$MovieToJson(model), + if (posterFieldValue != null) + _$MovieFieldMap['poster']!: posterFieldValue, + + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + + if (runtimeFieldValue != null) + _$MovieFieldMap['runtime']!: runtimeFieldValue, + + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value..remove('id'), + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Movie model, { + SetOptions? options, + FieldValue? posterFieldValue, + FieldValue? likesFieldValue, + FieldValue? titleFieldValue, + FieldValue? yearFieldValue, + FieldValue? runtimeFieldValue, + FieldValue? ratedFieldValue, + FieldValue? genreFieldValue, + FieldValue? tagsFieldValue, + }) { + final json = { + ..._$MovieToJson(model), + if (posterFieldValue != null) + _$MovieFieldMap['poster']!: posterFieldValue, + + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + + if (runtimeFieldValue != null) + _$MovieFieldMap['runtime']!: runtimeFieldValue, + + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value..remove('id'), + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Movie model, { + SetOptions? options, + FieldValue? posterFieldValue, + FieldValue? likesFieldValue, + FieldValue? titleFieldValue, + FieldValue? yearFieldValue, + FieldValue? runtimeFieldValue, + FieldValue? ratedFieldValue, + FieldValue? genreFieldValue, + FieldValue? tagsFieldValue, + }) { + final json = { + ..._$MovieToJson(model), + if (posterFieldValue != null) + _$MovieFieldMap['poster']!: posterFieldValue, + + if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, + + if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, + + if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, + + if (runtimeFieldValue != null) + _$MovieFieldMap['runtime']!: runtimeFieldValue, + + if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, + + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value..remove('id'), + ); + batch.set(castedReference, json, options); + } + + Future update({ + 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, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class MovieQuery implements QueryReference { + @override + MovieQuery limit(int limit); + + @override + MovieQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + MovieQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MovieQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MovieQuery wherePoster({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MovieQuery whereLikes({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MovieQuery whereTitle({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MovieQuery whereYear({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MovieQuery whereRuntime({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MovieQuery whereRated({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MovieQuery whereGenre({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + String? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + MovieQuery whereTags({ + Set? isEqualTo, + Set? isNotEqualTo, + Set? isLessThan, + Set? isLessThanOrEqualTo, + Set? isGreaterThan, + Set? isGreaterThanOrEqualTo, + String? arrayContains, + Set? arrayContainsAny, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + MovieQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByPoster({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByLikes({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByTitle({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByYear({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByRuntime({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByRated({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByGenre({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); + + MovieQuery orderByTags({ + bool descending = false, + Set? startAt, + Set? startAfter, + Set? endAt, + Set? endBefore, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }); +} + +class _$MovieQuery extends QueryReference + implements MovieQuery { + _$MovieQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(MovieQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(MovieQuerySnapshot._fromQuerySnapshot); + } + + @override + MovieQuery limit(int limit) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery limitToLast(int limit) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery wherePoster({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MovieFieldMap['poster']!, + isEqualTo: isEqualTo != _sentinel + ? _$MoviePerFieldToJson.poster(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MoviePerFieldToJson.poster(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$MoviePerFieldToJson.poster(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MoviePerFieldToJson.poster(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$MoviePerFieldToJson.poster(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MoviePerFieldToJson.poster(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.poster(e)), + whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.poster(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereLikes({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MovieFieldMap['likes']!, + isEqualTo: isEqualTo != _sentinel + ? _$MoviePerFieldToJson.likes(isEqualTo as int) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MoviePerFieldToJson.likes(isNotEqualTo as int) + : null, + isLessThan: isLessThan != null + ? _$MoviePerFieldToJson.likes(isLessThan as int) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MoviePerFieldToJson.likes(isLessThanOrEqualTo as int) + : null, + isGreaterThan: isGreaterThan != null + ? _$MoviePerFieldToJson.likes(isGreaterThan as int) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MoviePerFieldToJson.likes(isGreaterThanOrEqualTo as int) + : null, + whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.likes(e)), + whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.likes(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereTitle({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MovieFieldMap['title']!, + isEqualTo: isEqualTo != _sentinel + ? _$MoviePerFieldToJson.title(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MoviePerFieldToJson.title(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$MoviePerFieldToJson.title(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MoviePerFieldToJson.title(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$MoviePerFieldToJson.title(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MoviePerFieldToJson.title(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.title(e)), + whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.title(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereYear({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MovieFieldMap['year']!, + isEqualTo: isEqualTo != _sentinel + ? _$MoviePerFieldToJson.year(isEqualTo as int) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MoviePerFieldToJson.year(isNotEqualTo as int) + : null, + isLessThan: isLessThan != null + ? _$MoviePerFieldToJson.year(isLessThan as int) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MoviePerFieldToJson.year(isLessThanOrEqualTo as int) + : null, + isGreaterThan: isGreaterThan != null + ? _$MoviePerFieldToJson.year(isGreaterThan as int) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MoviePerFieldToJson.year(isGreaterThanOrEqualTo as int) + : null, + whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.year(e)), + whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.year(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereRuntime({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MovieFieldMap['runtime']!, + isEqualTo: isEqualTo != _sentinel + ? _$MoviePerFieldToJson.runtime(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MoviePerFieldToJson.runtime(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$MoviePerFieldToJson.runtime(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MoviePerFieldToJson.runtime(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$MoviePerFieldToJson.runtime(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MoviePerFieldToJson.runtime(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.runtime(e)), + whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.runtime(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereRated({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MovieFieldMap['rated']!, + isEqualTo: isEqualTo != _sentinel + ? _$MoviePerFieldToJson.rated(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MoviePerFieldToJson.rated(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$MoviePerFieldToJson.rated(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MoviePerFieldToJson.rated(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$MoviePerFieldToJson.rated(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MoviePerFieldToJson.rated(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.rated(e)), + whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.rated(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereGenre({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MovieFieldMap['genre']!, + isEqualTo: isEqualTo != _sentinel + ? _$MoviePerFieldToJson.genre(isEqualTo as List?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MoviePerFieldToJson.genre(isNotEqualTo as List?) + : null, + isLessThan: isLessThan != null + ? _$MoviePerFieldToJson.genre(isLessThan as List?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MoviePerFieldToJson.genre(isLessThanOrEqualTo as List?) + : null, + isGreaterThan: isGreaterThan != null + ? _$MoviePerFieldToJson.genre(isGreaterThan as List?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MoviePerFieldToJson.genre( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$MoviePerFieldToJson.genre([arrayContains as String]) as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$MoviePerFieldToJson.genre(arrayContainsAny) as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery whereTags({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + Set? arrayContainsAny, + bool? isNull, + }) { + return _$MovieQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MovieFieldMap['tags']!, + isEqualTo: isEqualTo != _sentinel + ? _$MoviePerFieldToJson.tags(isEqualTo as Set?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MoviePerFieldToJson.tags(isNotEqualTo as Set?) + : null, + isLessThan: isLessThan != null + ? _$MoviePerFieldToJson.tags(isLessThan as Set?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MoviePerFieldToJson.tags(isLessThanOrEqualTo as Set?) + : null, + isGreaterThan: isGreaterThan != null + ? _$MoviePerFieldToJson.tags(isGreaterThan as Set?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MoviePerFieldToJson.tags(isGreaterThanOrEqualTo as Set?) + : null, + arrayContains: arrayContains != null + ? (_$MoviePerFieldToJson.tags({arrayContains as String}) as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$MoviePerFieldToJson.tags(arrayContainsAny) as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MovieQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByPoster({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['poster']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.poster(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.poster(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.poster(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.poster(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByLikes({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['likes']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.likes(startAt as int), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.likes(startAfter as int), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.likes(endAt as int), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.likes(endBefore as int), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByTitle({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['title']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.title(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.title(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.title(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.title(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByYear({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['year']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.year(startAt as int), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.year(startAfter as int), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, _$MoviePerFieldToJson.year(endAt as int)], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.year(endBefore as int), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByRuntime({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['runtime']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.runtime(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.runtime(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.runtime(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.runtime(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByRated({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['rated']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.rated(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.rated(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.rated(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.rated(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByGenre({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['genre']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.genre(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.genre(startAfter as List?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.genre(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.genre(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MovieQuery orderByTags({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MovieDocumentSnapshot? startAtDocument, + MovieDocumentSnapshot? endAtDocument, + MovieDocumentSnapshot? endBeforeDocument, + MovieDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['tags']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.tags(startAt as Set?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.tags(startAfter as Set?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.tags(endAt as Set?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.tags(endBefore as Set?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MovieQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$MovieQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class MovieDocumentSnapshot extends FirestoreDocumentSnapshot { + MovieDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + MovieDocumentReference get reference { + return MovieDocumentReference(snapshot.reference); + } + + @override + final Movie? data; +} + +class MovieQuerySnapshot + extends FirestoreQuerySnapshot { + MovieQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory MovieQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { + final docs = snapshot.docs.map(MovieQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, MovieDocumentSnapshot._); + }).toList(); + + return MovieQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + MovieDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class MovieQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements MovieDocumentSnapshot { + MovieQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Movie data; + + @override + MovieDocumentReference get reference { + return MovieDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class CommentCollectionReference + implements + CommentQuery, + FirestoreCollectionReference { + factory CommentCollectionReference(DocumentReference parent) = + _$CommentCollectionReference; + + static Comment fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$CommentFromJson(snapshot.data()!); + } + + static Map toFirestore(Comment value, SetOptions? options) { + return _$CommentToJson(value); + } + + @override + CollectionReference get reference; + + /// A reference to the containing [MovieDocumentReference] if this is a subcollection. + MovieDocumentReference get parent; + + @override + CommentDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Comment value); +} + +class _$CommentCollectionReference extends _$CommentQuery + implements CommentCollectionReference { + factory _$CommentCollectionReference(DocumentReference parent) { + return _$CommentCollectionReference._( + MovieDocumentReference(parent), + parent + .collection('comments') + .withConverter( + fromFirestore: CommentCollectionReference.fromFirestore, + toFirestore: CommentCollectionReference.toFirestore, + ), + ); + } + + _$CommentCollectionReference._( + this.parent, + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + @override + final MovieDocumentReference parent; + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + CommentDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return CommentDocumentReference(reference.doc(id)); + } + + @override + Future add(Comment value) { + return reference.add(value).then((ref) => CommentDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$CommentCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class CommentDocumentReference + extends FirestoreDocumentReference { + factory CommentDocumentReference(DocumentReference reference) = + _$CommentDocumentReference; + + DocumentReference get reference; + + /// A reference to the [CommentCollectionReference] containing this document. + CommentCollectionReference get parent { + return _$CommentCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: MovieCollectionReference.fromFirestore, + toFirestore: MovieCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Comment model, { + SetOptions? options, + FieldValue authorNameFieldValue, + FieldValue messageFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Comment model, { + SetOptions? options, + FieldValue authorNameFieldValue, + FieldValue messageFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Comment model, { + SetOptions? options, + FieldValue authorNameFieldValue, + FieldValue messageFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String authorName, + FieldValue authorNameFieldValue, + String message, + FieldValue messageFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String authorName, + FieldValue authorNameFieldValue, + 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 + extends FirestoreDocumentReference + implements CommentDocumentReference { + _$CommentDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [CommentCollectionReference] containing this document. + CommentCollectionReference get parent { + return _$CommentCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: MovieCollectionReference.fromFirestore, + toFirestore: MovieCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots() { + return reference.snapshots().map(CommentDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(CommentDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(CommentDocumentSnapshot._); + } + + Future set( + Comment model, { + SetOptions? options, + FieldValue? authorNameFieldValue, + FieldValue? messageFieldValue, + }) async { + final json = { + ..._$CommentToJson(model), + if (authorNameFieldValue != null) + _$CommentFieldMap['authorName']!: authorNameFieldValue, + + if (messageFieldValue != null) + _$CommentFieldMap['message']!: messageFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Comment model, { + SetOptions? options, + FieldValue? authorNameFieldValue, + FieldValue? messageFieldValue, + }) { + final json = { + ..._$CommentToJson(model), + if (authorNameFieldValue != null) + _$CommentFieldMap['authorName']!: authorNameFieldValue, + + if (messageFieldValue != null) + _$CommentFieldMap['message']!: messageFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Comment model, { + SetOptions? options, + FieldValue? authorNameFieldValue, + FieldValue? messageFieldValue, + }) { + final json = { + ..._$CommentToJson(model), + if (authorNameFieldValue != null) + _$CommentFieldMap['authorName']!: authorNameFieldValue, + + if (messageFieldValue != null) + _$CommentFieldMap['message']!: messageFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? authorName = _sentinel, + FieldValue? authorNameFieldValue, + Object? message = _sentinel, + FieldValue? messageFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class CommentQuery + implements QueryReference { + @override + CommentQuery limit(int limit); + + @override + CommentQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + CommentQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + CommentQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + CommentQuery whereAuthorName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + CommentQuery whereMessage({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + CommentQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + CommentDocumentSnapshot? startAtDocument, + CommentDocumentSnapshot? endAtDocument, + CommentDocumentSnapshot? endBeforeDocument, + CommentDocumentSnapshot? startAfterDocument, + }); + + CommentQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + CommentDocumentSnapshot? startAtDocument, + CommentDocumentSnapshot? endAtDocument, + CommentDocumentSnapshot? endBeforeDocument, + CommentDocumentSnapshot? startAfterDocument, + }); + + CommentQuery orderByAuthorName({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + CommentDocumentSnapshot? startAtDocument, + CommentDocumentSnapshot? endAtDocument, + CommentDocumentSnapshot? endBeforeDocument, + CommentDocumentSnapshot? startAfterDocument, + }); + + CommentQuery orderByMessage({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + CommentDocumentSnapshot? startAtDocument, + CommentDocumentSnapshot? endAtDocument, + CommentDocumentSnapshot? endBeforeDocument, + CommentDocumentSnapshot? startAfterDocument, + }); +} + +class _$CommentQuery extends QueryReference + implements CommentQuery { + _$CommentQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(CommentQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(CommentQuerySnapshot._fromQuerySnapshot); + } + + @override + CommentQuery limit(int limit) { + return _$CommentQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + CommentQuery limitToLast(int limit) { + return _$CommentQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + CommentQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$CommentQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + CommentQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$CommentQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + CommentQuery whereAuthorName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$CommentQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$CommentFieldMap['authorName']!, + isEqualTo: isEqualTo != _sentinel + ? _$CommentPerFieldToJson.authorName(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$CommentPerFieldToJson.authorName(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$CommentPerFieldToJson.authorName(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$CommentPerFieldToJson.authorName(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$CommentPerFieldToJson.authorName(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$CommentPerFieldToJson.authorName( + isGreaterThanOrEqualTo as String, + ) + : null, + whereIn: whereIn?.map((e) => _$CommentPerFieldToJson.authorName(e)), + whereNotIn: whereNotIn?.map( + (e) => _$CommentPerFieldToJson.authorName(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + CommentQuery whereMessage({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$CommentQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$CommentFieldMap['message']!, + isEqualTo: isEqualTo != _sentinel + ? _$CommentPerFieldToJson.message(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$CommentPerFieldToJson.message(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$CommentPerFieldToJson.message(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$CommentPerFieldToJson.message(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$CommentPerFieldToJson.message(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$CommentPerFieldToJson.message(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$CommentPerFieldToJson.message(e)), + whereNotIn: whereNotIn?.map((e) => _$CommentPerFieldToJson.message(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + CommentQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + CommentDocumentSnapshot? startAtDocument, + CommentDocumentSnapshot? endAtDocument, + CommentDocumentSnapshot? endBeforeDocument, + CommentDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$CommentQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + CommentQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + CommentDocumentSnapshot? startAtDocument, + CommentDocumentSnapshot? endAtDocument, + CommentDocumentSnapshot? endBeforeDocument, + CommentDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$CommentQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + CommentQuery orderByAuthorName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + CommentDocumentSnapshot? startAtDocument, + CommentDocumentSnapshot? endAtDocument, + CommentDocumentSnapshot? endBeforeDocument, + CommentDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$CommentFieldMap['authorName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$CommentPerFieldToJson.authorName(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$CommentPerFieldToJson.authorName(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$CommentPerFieldToJson.authorName(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$CommentPerFieldToJson.authorName(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$CommentQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + CommentQuery orderByMessage({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + CommentDocumentSnapshot? startAtDocument, + CommentDocumentSnapshot? endAtDocument, + CommentDocumentSnapshot? endBeforeDocument, + CommentDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$CommentFieldMap['message']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$CommentPerFieldToJson.message(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$CommentPerFieldToJson.message(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$CommentPerFieldToJson.message(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$CommentPerFieldToJson.message(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$CommentQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$CommentQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class CommentDocumentSnapshot extends FirestoreDocumentSnapshot { + CommentDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + CommentDocumentReference get reference { + return CommentDocumentReference(snapshot.reference); + } + + @override + final Comment? data; +} + +class CommentQuerySnapshot + extends FirestoreQuerySnapshot { + CommentQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory CommentQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(CommentQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, CommentDocumentSnapshot._); + }).toList(); + + return CommentQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + CommentDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class CommentQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements CommentDocumentSnapshot { + CommentQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Comment data; + + @override + CommentDocumentReference get reference { + return CommentDocumentReference(snapshot.reference); + } +} + +// ************************************************************************** +// ValidatorGenerator +// ************************************************************************** + +void _$assertMovie(Movie instance) { + const Min(0).validate(instance.likes, 'likes'); + const Min(0).validate(instance.year, 'year'); +} diff --git a/packages/cloud_firestore_odm/example/lib/movie.g.dart b/packages/cloud_firestore_odm/example/lib/movie.g.dart index f12e30a..bacce0a 100644 --- a/packages/cloud_firestore_odm/example/lib/movie.g.dart +++ b/packages/cloud_firestore_odm/example/lib/movie.g.dart @@ -4,3399 +4,21 @@ part of 'movie.dart'; -// ************************************************************************** -// CollectionGenerator -// ************************************************************************** - -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore -// ignore_for_file: type=lint -// ignore_for_file: invalid_use_of_internal_member - -class _Sentinel { - const _Sentinel(); -} - -const _sentinel = _Sentinel(); - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class MovieCollectionReference - implements - MovieQuery, - FirestoreCollectionReference { - factory MovieCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$MovieCollectionReference; - - static Movie fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$MovieFromJson({'id': snapshot.id, ...?snapshot.data()}); - } - - static Map toFirestore( - Movie value, - SetOptions? options, - ) { - return {..._$MovieToJson(value)}..remove('id'); - } - - @override - CollectionReference get reference; - - @override - MovieDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Movie value); -} - -class _$MovieCollectionReference extends _$MovieQuery - implements MovieCollectionReference { - factory _$MovieCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$MovieCollectionReference._( - firestore.collection('firestore-example-app').withConverter( - fromFirestore: MovieCollectionReference.fromFirestore, - toFirestore: MovieCollectionReference.toFirestore, - ), - ); - } - - _$MovieCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - MovieDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return MovieDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Movie value) { - return reference.add(value).then((ref) => MovieDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$MovieCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class MovieDocumentReference - extends FirestoreDocumentReference { - factory MovieDocumentReference(DocumentReference reference) = - _$MovieDocumentReference; - - DocumentReference get reference; - - /// A reference to the [MovieCollectionReference] containing this document. - MovieCollectionReference get parent { - return _$MovieCollectionReference(reference.firestore); - } - - late final CommentCollectionReference comments = _$CommentCollectionReference( - reference, - ); - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Movie model, { - SetOptions? options, - FieldValue posterFieldValue, - FieldValue likesFieldValue, - FieldValue titleFieldValue, - FieldValue yearFieldValue, - FieldValue runtimeFieldValue, - FieldValue ratedFieldValue, - FieldValue genreFieldValue, - FieldValue tagsFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Movie model, { - SetOptions? options, - FieldValue posterFieldValue, - FieldValue likesFieldValue, - FieldValue titleFieldValue, - FieldValue yearFieldValue, - FieldValue runtimeFieldValue, - FieldValue ratedFieldValue, - FieldValue genreFieldValue, - FieldValue tagsFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Movie model, { - SetOptions? options, - FieldValue posterFieldValue, - FieldValue likesFieldValue, - FieldValue titleFieldValue, - FieldValue yearFieldValue, - FieldValue runtimeFieldValue, - FieldValue ratedFieldValue, - FieldValue genreFieldValue, - FieldValue tagsFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - 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, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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, - }); - - /// 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 - extends FirestoreDocumentReference - implements MovieDocumentReference { - _$MovieDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [MovieCollectionReference] containing this document. - MovieCollectionReference get parent { - return _$MovieCollectionReference(reference.firestore); - } - - late final CommentCollectionReference comments = _$CommentCollectionReference( - reference, - ); - - @override - Stream snapshots() { - return reference.snapshots().map(MovieDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(MovieDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(MovieDocumentSnapshot._); - } - - Future set( - Movie model, { - SetOptions? options, - FieldValue? posterFieldValue, - FieldValue? likesFieldValue, - FieldValue? titleFieldValue, - FieldValue? yearFieldValue, - FieldValue? runtimeFieldValue, - FieldValue? ratedFieldValue, - FieldValue? genreFieldValue, - FieldValue? tagsFieldValue, - }) async { - final json = { - ..._$MovieToJson(model), - if (posterFieldValue != null) - _$MovieFieldMap['poster']!: posterFieldValue, - if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, - if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, - if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, - if (runtimeFieldValue != null) - _$MovieFieldMap['runtime']!: runtimeFieldValue, - if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, - if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, - if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Movie model, { - SetOptions? options, - FieldValue? posterFieldValue, - FieldValue? likesFieldValue, - FieldValue? titleFieldValue, - FieldValue? yearFieldValue, - FieldValue? runtimeFieldValue, - FieldValue? ratedFieldValue, - FieldValue? genreFieldValue, - FieldValue? tagsFieldValue, - }) { - final json = { - ..._$MovieToJson(model), - if (posterFieldValue != null) - _$MovieFieldMap['poster']!: posterFieldValue, - if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, - if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, - if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, - if (runtimeFieldValue != null) - _$MovieFieldMap['runtime']!: runtimeFieldValue, - if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, - if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, - if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Movie model, { - SetOptions? options, - FieldValue? posterFieldValue, - FieldValue? likesFieldValue, - FieldValue? titleFieldValue, - FieldValue? yearFieldValue, - FieldValue? runtimeFieldValue, - FieldValue? ratedFieldValue, - FieldValue? genreFieldValue, - FieldValue? tagsFieldValue, - }) { - final json = { - ..._$MovieToJson(model), - if (posterFieldValue != null) - _$MovieFieldMap['poster']!: posterFieldValue, - if (likesFieldValue != null) _$MovieFieldMap['likes']!: likesFieldValue, - if (titleFieldValue != null) _$MovieFieldMap['title']!: titleFieldValue, - if (yearFieldValue != null) _$MovieFieldMap['year']!: yearFieldValue, - if (runtimeFieldValue != null) - _$MovieFieldMap['runtime']!: runtimeFieldValue, - if (ratedFieldValue != null) _$MovieFieldMap['rated']!: ratedFieldValue, - if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, - if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - 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, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class MovieQuery implements QueryReference { - @override - MovieQuery limit(int limit); - - @override - MovieQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - MovieQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MovieQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MovieQuery wherePoster({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MovieQuery whereLikes({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MovieQuery whereTitle({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MovieQuery whereYear({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MovieQuery whereRuntime({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MovieQuery whereRated({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MovieQuery whereGenre({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - String? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - MovieQuery whereTags({ - Set? isEqualTo, - Set? isNotEqualTo, - Set? isLessThan, - Set? isLessThanOrEqualTo, - Set? isGreaterThan, - Set? isGreaterThanOrEqualTo, - String? arrayContains, - Set? arrayContainsAny, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - MovieQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByPoster({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByLikes({ - bool descending = false, - int startAt, - int startAfter, - int endAt, - int endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByTitle({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByYear({ - bool descending = false, - int startAt, - int startAfter, - int endAt, - int endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByRuntime({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByRated({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByGenre({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); - - MovieQuery orderByTags({ - bool descending = false, - Set? startAt, - Set? startAfter, - Set? endAt, - Set? endBefore, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }); -} - -class _$MovieQuery extends QueryReference - implements MovieQuery { - _$MovieQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(MovieQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(MovieQuerySnapshot._fromQuerySnapshot); - } - - @override - MovieQuery limit(int limit) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery limitToLast(int limit) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery wherePoster({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MovieFieldMap['poster']!, - isEqualTo: isEqualTo != _sentinel - ? _$MoviePerFieldToJson.poster(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MoviePerFieldToJson.poster(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$MoviePerFieldToJson.poster(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MoviePerFieldToJson.poster(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$MoviePerFieldToJson.poster(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson.poster(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.poster(e)), - whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.poster(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereLikes({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MovieFieldMap['likes']!, - isEqualTo: isEqualTo != _sentinel - ? _$MoviePerFieldToJson.likes(isEqualTo as int) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MoviePerFieldToJson.likes(isNotEqualTo as int) - : null, - isLessThan: isLessThan != null - ? _$MoviePerFieldToJson.likes(isLessThan as int) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MoviePerFieldToJson.likes(isLessThanOrEqualTo as int) - : null, - isGreaterThan: isGreaterThan != null - ? _$MoviePerFieldToJson.likes(isGreaterThan as int) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson.likes(isGreaterThanOrEqualTo as int) - : null, - whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.likes(e)), - whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.likes(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereTitle({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MovieFieldMap['title']!, - isEqualTo: isEqualTo != _sentinel - ? _$MoviePerFieldToJson.title(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MoviePerFieldToJson.title(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$MoviePerFieldToJson.title(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MoviePerFieldToJson.title(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$MoviePerFieldToJson.title(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson.title(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.title(e)), - whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.title(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereYear({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MovieFieldMap['year']!, - isEqualTo: isEqualTo != _sentinel - ? _$MoviePerFieldToJson.year(isEqualTo as int) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MoviePerFieldToJson.year(isNotEqualTo as int) - : null, - isLessThan: isLessThan != null - ? _$MoviePerFieldToJson.year(isLessThan as int) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MoviePerFieldToJson.year(isLessThanOrEqualTo as int) - : null, - isGreaterThan: isGreaterThan != null - ? _$MoviePerFieldToJson.year(isGreaterThan as int) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson.year(isGreaterThanOrEqualTo as int) - : null, - whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.year(e)), - whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.year(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereRuntime({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MovieFieldMap['runtime']!, - isEqualTo: isEqualTo != _sentinel - ? _$MoviePerFieldToJson.runtime(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MoviePerFieldToJson.runtime(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$MoviePerFieldToJson.runtime(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MoviePerFieldToJson.runtime(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$MoviePerFieldToJson.runtime(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson.runtime(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.runtime(e)), - whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.runtime(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereRated({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MovieFieldMap['rated']!, - isEqualTo: isEqualTo != _sentinel - ? _$MoviePerFieldToJson.rated(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MoviePerFieldToJson.rated(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$MoviePerFieldToJson.rated(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MoviePerFieldToJson.rated(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$MoviePerFieldToJson.rated(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson.rated(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.rated(e)), - whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.rated(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereGenre({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MovieFieldMap['genre']!, - isEqualTo: isEqualTo != _sentinel - ? _$MoviePerFieldToJson.genre(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MoviePerFieldToJson.genre(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$MoviePerFieldToJson.genre(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MoviePerFieldToJson.genre(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$MoviePerFieldToJson.genre(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson - .genre(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$MoviePerFieldToJson.genre([arrayContains as String]) as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$MoviePerFieldToJson.genre(arrayContainsAny) as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery whereTags({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - Set? arrayContainsAny, - bool? isNull, - }) { - return _$MovieQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MovieFieldMap['tags']!, - isEqualTo: isEqualTo != _sentinel - ? _$MoviePerFieldToJson.tags(isEqualTo as Set?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MoviePerFieldToJson.tags(isNotEqualTo as Set?) - : null, - isLessThan: isLessThan != null - ? _$MoviePerFieldToJson.tags(isLessThan as Set?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MoviePerFieldToJson.tags(isLessThanOrEqualTo as Set?) - : null, - isGreaterThan: isGreaterThan != null - ? _$MoviePerFieldToJson.tags(isGreaterThan as Set?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson.tags(isGreaterThanOrEqualTo as Set?) - : null, - arrayContains: arrayContains != null - ? (_$MoviePerFieldToJson.tags({arrayContains as String}) as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$MoviePerFieldToJson.tags(arrayContainsAny) as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MovieQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByPoster({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['poster']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByLikes({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['likes']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByTitle({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['title']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByYear({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['year']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByRuntime({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['runtime']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByRated({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['rated']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByGenre({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['genre']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MovieQuery orderByTags({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MovieDocumentSnapshot? startAtDocument, - MovieDocumentSnapshot? endAtDocument, - MovieDocumentSnapshot? endBeforeDocument, - MovieDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['tags']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MovieQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$MovieQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class MovieDocumentSnapshot extends FirestoreDocumentSnapshot { - MovieDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - MovieDocumentReference get reference { - return MovieDocumentReference( - snapshot.reference, - ); - } - - @override - final Movie? data; -} - -class MovieQuerySnapshot - extends FirestoreQuerySnapshot { - MovieQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory MovieQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(MovieQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - MovieDocumentSnapshot._, - ); - }).toList(); - - return MovieQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - MovieDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class MovieQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements MovieDocumentSnapshot { - MovieQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Movie data; - - @override - MovieDocumentReference get reference { - return MovieDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class CommentCollectionReference - implements - CommentQuery, - FirestoreCollectionReference { - factory CommentCollectionReference( - DocumentReference parent, - ) = _$CommentCollectionReference; - - static Comment fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$CommentFromJson(snapshot.data()!); - } - - static Map toFirestore( - Comment value, - SetOptions? options, - ) { - return _$CommentToJson(value); - } - - @override - CollectionReference get reference; - - /// A reference to the containing [MovieDocumentReference] if this is a subcollection. - MovieDocumentReference get parent; - - @override - CommentDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Comment value); -} - -class _$CommentCollectionReference extends _$CommentQuery - implements CommentCollectionReference { - factory _$CommentCollectionReference( - DocumentReference parent, - ) { - return _$CommentCollectionReference._( - MovieDocumentReference(parent), - parent.collection('comments').withConverter( - fromFirestore: CommentCollectionReference.fromFirestore, - toFirestore: CommentCollectionReference.toFirestore, - ), - ); - } - - _$CommentCollectionReference._( - this.parent, - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - @override - final MovieDocumentReference parent; - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - CommentDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return CommentDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Comment value) { - return reference.add(value).then((ref) => CommentDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$CommentCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class CommentDocumentReference - extends FirestoreDocumentReference { - factory CommentDocumentReference(DocumentReference reference) = - _$CommentDocumentReference; - - DocumentReference get reference; - - /// A reference to the [CommentCollectionReference] containing this document. - CommentCollectionReference get parent { - return _$CommentCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: MovieCollectionReference.fromFirestore, - toFirestore: MovieCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Comment model, { - SetOptions? options, - FieldValue authorNameFieldValue, - FieldValue messageFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Comment model, { - SetOptions? options, - FieldValue authorNameFieldValue, - FieldValue messageFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Comment model, { - SetOptions? options, - FieldValue authorNameFieldValue, - FieldValue messageFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String authorName, - FieldValue authorNameFieldValue, - String message, - FieldValue messageFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - String authorName, - FieldValue authorNameFieldValue, - 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 - extends FirestoreDocumentReference - implements CommentDocumentReference { - _$CommentDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [CommentCollectionReference] containing this document. - CommentCollectionReference get parent { - return _$CommentCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: MovieCollectionReference.fromFirestore, - toFirestore: MovieCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots() { - return reference.snapshots().map(CommentDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(CommentDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(CommentDocumentSnapshot._); - } - - Future set( - Comment model, { - SetOptions? options, - FieldValue? authorNameFieldValue, - FieldValue? messageFieldValue, - }) async { - final json = { - ..._$CommentToJson(model), - if (authorNameFieldValue != null) - _$CommentFieldMap['authorName']!: authorNameFieldValue, - if (messageFieldValue != null) - _$CommentFieldMap['message']!: messageFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Comment model, { - SetOptions? options, - FieldValue? authorNameFieldValue, - FieldValue? messageFieldValue, - }) { - final json = { - ..._$CommentToJson(model), - if (authorNameFieldValue != null) - _$CommentFieldMap['authorName']!: authorNameFieldValue, - if (messageFieldValue != null) - _$CommentFieldMap['message']!: messageFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Comment model, { - SetOptions? options, - FieldValue? authorNameFieldValue, - FieldValue? messageFieldValue, - }) { - final json = { - ..._$CommentToJson(model), - if (authorNameFieldValue != null) - _$CommentFieldMap['authorName']!: authorNameFieldValue, - if (messageFieldValue != null) - _$CommentFieldMap['message']!: messageFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? authorName = _sentinel, - FieldValue? authorNameFieldValue, - Object? message = _sentinel, - FieldValue? messageFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class CommentQuery - implements QueryReference { - @override - CommentQuery limit(int limit); - - @override - CommentQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - CommentQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - CommentQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - CommentQuery whereAuthorName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - CommentQuery whereMessage({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - CommentQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - CommentDocumentSnapshot? startAtDocument, - CommentDocumentSnapshot? endAtDocument, - CommentDocumentSnapshot? endBeforeDocument, - CommentDocumentSnapshot? startAfterDocument, - }); - - CommentQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - CommentDocumentSnapshot? startAtDocument, - CommentDocumentSnapshot? endAtDocument, - CommentDocumentSnapshot? endBeforeDocument, - CommentDocumentSnapshot? startAfterDocument, - }); - - CommentQuery orderByAuthorName({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - CommentDocumentSnapshot? startAtDocument, - CommentDocumentSnapshot? endAtDocument, - CommentDocumentSnapshot? endBeforeDocument, - CommentDocumentSnapshot? startAfterDocument, - }); - - CommentQuery orderByMessage({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - CommentDocumentSnapshot? startAtDocument, - CommentDocumentSnapshot? endAtDocument, - CommentDocumentSnapshot? endBeforeDocument, - CommentDocumentSnapshot? startAfterDocument, - }); -} - -class _$CommentQuery extends QueryReference - implements CommentQuery { - _$CommentQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(CommentQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(CommentQuerySnapshot._fromQuerySnapshot); - } - - @override - CommentQuery limit(int limit) { - return _$CommentQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - CommentQuery limitToLast(int limit) { - return _$CommentQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - CommentQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$CommentQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - CommentQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$CommentQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - CommentQuery whereAuthorName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$CommentQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$CommentFieldMap['authorName']!, - isEqualTo: isEqualTo != _sentinel - ? _$CommentPerFieldToJson.authorName(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$CommentPerFieldToJson.authorName(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$CommentPerFieldToJson.authorName(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$CommentPerFieldToJson.authorName(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$CommentPerFieldToJson.authorName(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$CommentPerFieldToJson - .authorName(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$CommentPerFieldToJson.authorName(e)), - whereNotIn: - whereNotIn?.map((e) => _$CommentPerFieldToJson.authorName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - CommentQuery whereMessage({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$CommentQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$CommentFieldMap['message']!, - isEqualTo: isEqualTo != _sentinel - ? _$CommentPerFieldToJson.message(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$CommentPerFieldToJson.message(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$CommentPerFieldToJson.message(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$CommentPerFieldToJson.message(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$CommentPerFieldToJson.message(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$CommentPerFieldToJson.message(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$CommentPerFieldToJson.message(e)), - whereNotIn: whereNotIn?.map((e) => _$CommentPerFieldToJson.message(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - CommentQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - CommentDocumentSnapshot? startAtDocument, - CommentDocumentSnapshot? endAtDocument, - CommentDocumentSnapshot? endBeforeDocument, - CommentDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$CommentQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - CommentQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - CommentDocumentSnapshot? startAtDocument, - CommentDocumentSnapshot? endAtDocument, - CommentDocumentSnapshot? endBeforeDocument, - CommentDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$CommentQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - CommentQuery orderByAuthorName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - CommentDocumentSnapshot? startAtDocument, - CommentDocumentSnapshot? endAtDocument, - CommentDocumentSnapshot? endBeforeDocument, - CommentDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$CommentFieldMap['authorName']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$CommentQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - CommentQuery orderByMessage({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - CommentDocumentSnapshot? startAtDocument, - CommentDocumentSnapshot? endAtDocument, - CommentDocumentSnapshot? endBeforeDocument, - CommentDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$CommentFieldMap['message']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$CommentQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$CommentQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class CommentDocumentSnapshot extends FirestoreDocumentSnapshot { - CommentDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - CommentDocumentReference get reference { - return CommentDocumentReference( - snapshot.reference, - ); - } - - @override - final Comment? data; -} - -class CommentQuerySnapshot - extends FirestoreQuerySnapshot { - CommentQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory CommentQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(CommentQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - CommentDocumentSnapshot._, - ); - }).toList(); - - return CommentQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - CommentDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class CommentQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements CommentDocumentSnapshot { - CommentQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Comment data; - - @override - CommentDocumentReference get reference { - return CommentDocumentReference(snapshot.reference); - } -} - -// ************************************************************************** -// ValidatorGenerator -// ************************************************************************** - -void _$assertMovie(Movie instance) { - const Min(0).validate(instance.likes, 'likes'); - const Min(0).validate(instance.year, 'year'); -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** Movie _$MovieFromJson(Map json) => Movie( - genre: - (json['genre'] as List?)?.map((e) => e as String).toList(), - tags: (json['tags'] as List?)?.map((e) => e as String).toSet(), - likes: (json['likes'] as num).toInt(), - poster: json['poster'] as String, - rated: json['rated'] as String, - runtime: json['runtime'] as String, - title: json['title'] as String, - year: (json['year'] as num).toInt(), - id: json['id'] as String, - ); + genre: (json['genre'] as List?)?.map((e) => e as String).toList(), + tags: (json['tags'] as List?)?.map((e) => e as String).toSet(), + likes: (json['likes'] as num).toInt(), + poster: json['poster'] as String, + rated: json['rated'] as String, + runtime: json['runtime'] as String, + title: json['title'] as String, + year: (json['year'] as num).toInt(), + id: json['id'] as String, +); const _$MovieFieldMap = { 'id': 'id', @@ -3433,21 +55,21 @@ abstract class _$MoviePerFieldToJson { } Map _$MovieToJson(Movie instance) => { - 'id': instance.id, - 'poster': instance.poster, - 'likes': instance.likes, - 'title': instance.title, - 'year': instance.year, - 'runtime': instance.runtime, - 'rated': instance.rated, - 'genre': instance.genre, - 'tags': instance.tags?.toList(), - }; + 'id': instance.id, + 'poster': instance.poster, + 'likes': instance.likes, + 'title': instance.title, + 'year': instance.year, + 'runtime': instance.runtime, + 'rated': instance.rated, + 'genre': instance.genre, + 'tags': instance.tags?.toList(), +}; Comment _$CommentFromJson(Map json) => Comment( - authorName: json['authorName'] as String, - message: json['message'] as String, - ); + authorName: json['authorName'] as String, + message: json['message'] as String, +); const _$CommentFieldMap = { 'authorName': 'authorName', @@ -3463,6 +85,6 @@ abstract class _$CommentPerFieldToJson { } Map _$CommentToJson(Comment instance) => { - 'authorName': instance.authorName, - 'message': instance.message, - }; + 'authorName': instance.authorName, + 'message': instance.message, +}; diff --git a/packages/cloud_firestore_odm/example/pubspec.yaml b/packages/cloud_firestore_odm/example/pubspec.yaml index f7354cb..3ffb645 100644 --- a/packages/cloud_firestore_odm/example/pubspec.yaml +++ b/packages/cloud_firestore_odm/example/pubspec.yaml @@ -2,36 +2,37 @@ name: cloud_firestore_odm_example publish_to: none environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.8.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 - cloud_firestore_odm: ^1.0.0-dev.85 - firebase_core: ^3.0.0 + cloud_firestore: ^6.0.0 + cloud_firestore_odm: ^2.0.0 + firebase_core: ^4.0.0 flutter: sdk: flutter - freezed_annotation: ^2.2.0 - json_annotation: ^4.8.1 + freezed_annotation: ^3.1.0 + json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: - build_runner: ^2.4.2 + build_runner: ^2.8.0 cloud_firestore_odm_generator: path: ../../cloud_firestore_odm_generator cloud_firestore_odm_generator_integration_test: path: ../../cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test flutter_test: sdk: flutter - freezed: ^2.3.2 + freezed: ^3.2.0 http: ^1.0.0 integration_test: sdk: flutter - json_serializable: ^6.6.1 + json_serializable: ^6.11.0 mockito: ^5.0.0 dependency_overrides: cloud_firestore_odm: path: ../ + test_api: ^0.7.7 flutter: uses-material-design: true diff --git a/packages/cloud_firestore_odm/example/web/index.html b/packages/cloud_firestore_odm/example/web/index.html index ab4fd86..86c769e 100644 --- a/packages/cloud_firestore_odm/example/web/index.html +++ b/packages/cloud_firestore_odm/example/web/index.html @@ -30,72 +30,6 @@ - - + diff --git a/packages/cloud_firestore_odm/pubspec.yaml b/packages/cloud_firestore_odm/pubspec.yaml index 1873718..2fa60f2 100644 --- a/packages/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/pubspec.yaml @@ -2,21 +2,26 @@ name: cloud_firestore_odm description: An ODM for Firebase Cloud Firestore (cloud_firestore). homepage: https://github.com/firebaseextended/firestoreodm-flutter repository: https://github.com/firebaseextended/firestoreodm-flutter -version: 1.0.0-dev.88 +version: 2.0.0 false_secrets: - example/** environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.9.2 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 + cloud_firestore: ^6.0.0 flutter: sdk: flutter - json_annotation: ^4.8.1 + json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: flutter_test: sdk: flutter + test: ^1.26.3 + +dependency_overrides: + test_api: ^0.7.7 + # custom_lint_visitor: ^1.0.0+8.1.1 diff --git a/packages/cloud_firestore_odm_generator/CHANGELOG.md b/packages/cloud_firestore_odm_generator/CHANGELOG.md index 28119ba..cf94899 100644 --- a/packages/cloud_firestore_odm_generator/CHANGELOG.md +++ b/packages/cloud_firestore_odm_generator/CHANGELOG.md @@ -1,3 +1,19 @@ +## 2.0.0 +- **BREAKING**: Must include a "part '.firebase.dart';" instead of just part "'.g.dart';". This is because of compatibilty with Riverpod ^3. + +## 1.3.0 +- **CHORE**: upgraded packages to support analyzer ^8 and min sdk to 3.8.0 + +## 1.2.0 +- **FIX**: `set`, `batchSet` and `transactionSet` methods would keep the `@ID() id` in the object in DB. +- **CHORE**: Update cloud_firestore to ^6.0.0 + +## 1.1.0 + +- **FIX**: Resolve compatibility issues with Freezed 3.0.0 and above +- **FEAT**: Support analyzer: ^7.0.0 and source_gen: ^2.0.0 +- **CHORE**: Update dependencies to latest versions + ## 1.0.0-dev.90 - 2025-02-23 - Ignore static getters on annotated classes (thanks to @Rexios80) diff --git a/packages/cloud_firestore_odm_generator/build.yaml b/packages/cloud_firestore_odm_generator/build.yaml index 763e288..37aa5f9 100644 --- a/packages/cloud_firestore_odm_generator/build.yaml +++ b/packages/cloud_firestore_odm_generator/build.yaml @@ -12,8 +12,12 @@ builders: cloud_firestore_odm_generator: import: "package:cloud_firestore_odm_generator/cloud_firestore_odm_generator.dart" builder_factories: ["firebase"] - build_extensions: { ".dart": [".firebase.g.part"] } + build_extensions: { ".dart": [".firebase.dart"] } auto_apply: dependents - build_to: cache + build_to: source + # build_extensions: { ".dart": [".firebase.g.part"] } + # auto_apply: dependents + # build_to: cache applies_builders: ["source_gen|combining_builder"] required_inputs: [".freezed.dart"] + runs_before: ["riverpod_generator|riverpod_generator"] diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/build.yaml b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/build.yaml index d574b77..b278e45 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/build.yaml +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/build.yaml @@ -1,7 +1,16 @@ targets: $default: builders: + freezed: + enabled: true + cloud_firestore_odm_generator: + enabled: true json_serializable: + enabled: true options: create_field_map: true - create_per_field_to_json: true \ No newline at end of file + create_per_field_to_json: true + riverpod_generator: + enabled: true + options: + # Riverpod generator options can be configured here if needed diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart index 4453f8b..9b21c8f 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.dart @@ -8,12 +8,13 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; +part 'freezed.firebase.dart'; part 'freezed.freezed.dart'; part 'freezed.g.dart'; @Collection('freezed-test') @freezed -class Person with _$Person { +abstract class Person with _$Person { @JsonSerializable(fieldRename: FieldRename.snake) factory Person({ required String firstName, @@ -27,10 +28,28 @@ class Person with _$Person { final personRef = PersonCollectionReference(); @Collection('freezed-test') +final publicRedirectedRef = PublicRedirectedCollectionReference(); + @freezed -class PublicRedirected with _$PublicRedirected { +abstract class PublicRedirected with _$PublicRedirected { factory PublicRedirected({required String value}) = PublicRedirected2; - factory PublicRedirected.fromJson(Map json) => - _$PublicRedirectedFromJson(json); + factory PublicRedirected.fromJson(Map json) => _$PublicRedirectedFromJson(json); } + +/// Freezed 3.x mixed mode +/// +/// Simple classes +@freezed +@JsonSerializable() +class SimpleFreezed with _$SimpleFreezed { + const SimpleFreezed({required this.a}); + factory SimpleFreezed.fromJson(Map json) => _$SimpleFreezedFromJson(json); + + @override + final int a; + Map toJson() => _$SimpleFreezedToJson(this); +} + +@Collection('freezed-test') +final simpleFreezedRef = SimpleFreezedCollectionReference(); diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.firebase.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.firebase.dart new file mode 100644 index 0000000..6092471 --- /dev/null +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.firebase.dart @@ -0,0 +1,3082 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'freezed.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class PersonCollectionReference + implements + PersonQuery, + FirestoreCollectionReference { + factory PersonCollectionReference([FirebaseFirestore? firestore]) = + _$PersonCollectionReference; + + static Person fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return Person.fromJson(snapshot.data()!); + } + + static Map toFirestore(Person value, SetOptions? options) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + PersonDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Person value); +} + +class _$PersonCollectionReference extends _$PersonQuery + implements PersonCollectionReference { + factory _$PersonCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$PersonCollectionReference._( + firestore + .collection('freezed-test') + .withConverter( + fromFirestore: PersonCollectionReference.fromFirestore, + toFirestore: PersonCollectionReference.toFirestore, + ), + ); + } + + _$PersonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + PersonDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return PersonDocumentReference(reference.doc(id)); + } + + @override + Future add(Person value) { + return reference.add(value).then((ref) => PersonDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$PersonCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class PersonDocumentReference + extends FirestoreDocumentReference { + factory PersonDocumentReference(DocumentReference reference) = + _$PersonDocumentReference; + + DocumentReference get reference; + + /// A reference to the [PersonCollectionReference] containing this document. + PersonCollectionReference get parent { + return _$PersonCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Person model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Person model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Person model, { + SetOptions? options, + FieldValue firstNameFieldValue, + FieldValue lastNameFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String firstName, + FieldValue firstNameFieldValue, + String lastName, + FieldValue lastNameFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String firstName, + FieldValue firstNameFieldValue, + 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 + extends FirestoreDocumentReference + implements PersonDocumentReference { + _$PersonDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [PersonCollectionReference] containing this document. + PersonCollectionReference get parent { + return _$PersonCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(PersonDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(PersonDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(PersonDocumentSnapshot._); + } + + Future set( + Person model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) async { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Person model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Person model, { + SetOptions? options, + FieldValue? firstNameFieldValue, + FieldValue? lastNameFieldValue, + }) { + final json = { + ...model.toJson(), + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? firstName = _sentinel, + FieldValue? firstNameFieldValue, + Object? lastName = _sentinel, + FieldValue? lastNameFieldValue, + }) async { + 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) + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastName != _sentinel) + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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) + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastName != _sentinel) + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + 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) + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + + if (firstNameFieldValue != null) + _$PersonFieldMap['firstName']!: firstNameFieldValue, + + if (lastName != _sentinel) + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + + if (lastNameFieldValue != null) + _$PersonFieldMap['lastName']!: lastNameFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is PersonDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class PersonQuery + implements QueryReference { + @override + PersonQuery limit(int limit); + + @override + PersonQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + PersonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PersonQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PersonQuery whereFirstName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PersonQuery whereLastName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + PersonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }); + + PersonQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }); + + PersonQuery orderByFirstName({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }); + + PersonQuery orderByLastName({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }); +} + +class _$PersonQuery extends QueryReference + implements PersonQuery { + _$PersonQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(PersonQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(PersonQuerySnapshot._fromQuerySnapshot); + } + + @override + PersonQuery limit(int limit) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery limitToLast(int limit) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery whereFirstName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PersonFieldMap['firstName']!, + isEqualTo: isEqualTo != _sentinel + ? _$PersonPerFieldToJson.firstName(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PersonPerFieldToJson.firstName(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PersonPerFieldToJson.firstName(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PersonPerFieldToJson.firstName(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$PersonPerFieldToJson.firstName(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PersonPerFieldToJson.firstName(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery whereLastName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PersonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PersonFieldMap['lastName']!, + isEqualTo: isEqualTo != _sentinel + ? _$PersonPerFieldToJson.lastName(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PersonPerFieldToJson.lastName(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PersonPerFieldToJson.lastName(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PersonPerFieldToJson.lastName(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$PersonPerFieldToJson.lastName(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PersonPerFieldToJson.lastName(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PersonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PersonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PersonQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PersonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PersonQuery orderByFirstName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['firstName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.firstName(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.firstName(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.firstName(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.firstName(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PersonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PersonQuery orderByLastName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PersonDocumentSnapshot? startAtDocument, + PersonDocumentSnapshot? endAtDocument, + PersonDocumentSnapshot? endBeforeDocument, + PersonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['lastName']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.lastName(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.lastName(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.lastName(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.lastName(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PersonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$PersonQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { + PersonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + PersonDocumentReference get reference { + return PersonDocumentReference(snapshot.reference); + } + + @override + final Person? data; +} + +class PersonQuerySnapshot + extends FirestoreQuerySnapshot { + PersonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory PersonQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, PersonDocumentSnapshot._); + }).toList(); + + return PersonQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements PersonDocumentSnapshot { + PersonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Person data; + + @override + PersonDocumentReference get reference { + return PersonDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class PublicRedirectedCollectionReference + implements + PublicRedirectedQuery, + FirestoreCollectionReference< + PublicRedirected, + PublicRedirectedQuerySnapshot + > { + factory PublicRedirectedCollectionReference([FirebaseFirestore? firestore]) = + _$PublicRedirectedCollectionReference; + + static PublicRedirected fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return PublicRedirected.fromJson(snapshot.data()!); + } + + static Map toFirestore( + PublicRedirected value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + PublicRedirectedDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(PublicRedirected value); +} + +class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery + implements PublicRedirectedCollectionReference { + factory _$PublicRedirectedCollectionReference([ + FirebaseFirestore? firestore, + ]) { + firestore ??= FirebaseFirestore.instance; + + return _$PublicRedirectedCollectionReference._( + firestore + .collection('freezed-test') + .withConverter( + fromFirestore: PublicRedirectedCollectionReference.fromFirestore, + toFirestore: PublicRedirectedCollectionReference.toFirestore, + ), + ); + } + + _$PublicRedirectedCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + PublicRedirectedDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return PublicRedirectedDocumentReference(reference.doc(id)); + } + + @override + Future add(PublicRedirected value) { + return reference + .add(value) + .then((ref) => PublicRedirectedDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$PublicRedirectedCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class PublicRedirectedDocumentReference + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > { + factory PublicRedirectedDocumentReference( + DocumentReference reference, + ) = _$PublicRedirectedDocumentReference; + + DocumentReference get reference; + + /// A reference to the [PublicRedirectedCollectionReference] containing this document. + PublicRedirectedCollectionReference get parent { + return _$PublicRedirectedCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + PublicRedirected model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + PublicRedirected model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + PublicRedirected model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({String value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > + implements PublicRedirectedDocumentReference { + _$PublicRedirectedDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [PublicRedirectedCollectionReference] containing this document. + PublicRedirectedCollectionReference get parent { + return _$PublicRedirectedCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(PublicRedirectedDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(PublicRedirectedDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); + } + + Future set( + PublicRedirected model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + PublicRedirected model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + PublicRedirected model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) { + assert( + value == _sentinel || valueFieldValue == null, + "Cannot specify both value and valueFieldValue", + ); + final json = { + if (value != _sentinel) + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + 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) + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + + if (valueFieldValue != null) + _$PublicRedirected2FieldMap['value']!: valueFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is PublicRedirectedDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class PublicRedirectedQuery + implements QueryReference { + @override + PublicRedirectedQuery limit(int limit); + + @override + PublicRedirectedQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + PublicRedirectedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PublicRedirectedQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PublicRedirectedQuery whereValue({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + PublicRedirectedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }); + + PublicRedirectedQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }); + + PublicRedirectedQuery orderByValue({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }); +} + +class _$PublicRedirectedQuery + extends QueryReference + implements PublicRedirectedQuery { + _$PublicRedirectedQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + PublicRedirectedQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(PublicRedirectedQuerySnapshot._fromQuerySnapshot); + } + + @override + PublicRedirectedQuery limit(int limit) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery limitToLast(int limit) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PublicRedirected2FieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$PublicRedirected2PerFieldToJson.value(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PublicRedirected2PerFieldToJson.value(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PublicRedirected2PerFieldToJson.value(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PublicRedirected2PerFieldToJson.value( + isLessThanOrEqualTo as String, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$PublicRedirected2PerFieldToJson.value(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PublicRedirected2PerFieldToJson.value( + isGreaterThanOrEqualTo as String, + ) + : null, + whereIn: whereIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PublicRedirectedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PublicRedirectedQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PublicRedirectedQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PublicRedirectedDocumentSnapshot? startAtDocument, + PublicRedirectedDocumentSnapshot? endAtDocument, + PublicRedirectedDocumentSnapshot? endBeforeDocument, + PublicRedirectedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PublicRedirected2FieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PublicRedirected2PerFieldToJson.value(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PublicRedirected2PerFieldToJson.value(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PublicRedirected2PerFieldToJson.value(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PublicRedirected2PerFieldToJson.value(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PublicRedirectedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$PublicRedirectedQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class PublicRedirectedDocumentSnapshot + extends FirestoreDocumentSnapshot { + PublicRedirectedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + PublicRedirectedDocumentReference get reference { + return PublicRedirectedDocumentReference(snapshot.reference); + } + + @override + final PublicRedirected? data; +} + +class PublicRedirectedQuerySnapshot + extends + FirestoreQuerySnapshot< + PublicRedirected, + PublicRedirectedQueryDocumentSnapshot + > { + PublicRedirectedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory PublicRedirectedQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(PublicRedirectedQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, PublicRedirectedDocumentSnapshot._); + }).toList(); + + return PublicRedirectedQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) + decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> + docChanges; +} + +class PublicRedirectedQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements PublicRedirectedDocumentSnapshot { + PublicRedirectedQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final PublicRedirected data; + + @override + PublicRedirectedDocumentReference get reference { + return PublicRedirectedDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class SimpleFreezedCollectionReference + implements + SimpleFreezedQuery, + FirestoreCollectionReference< + SimpleFreezed, + SimpleFreezedQuerySnapshot + > { + factory SimpleFreezedCollectionReference([FirebaseFirestore? firestore]) = + _$SimpleFreezedCollectionReference; + + static SimpleFreezed fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return SimpleFreezed.fromJson(snapshot.data()!); + } + + static Map toFirestore( + SimpleFreezed value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + SimpleFreezedDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(SimpleFreezed value); +} + +class _$SimpleFreezedCollectionReference extends _$SimpleFreezedQuery + implements SimpleFreezedCollectionReference { + factory _$SimpleFreezedCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$SimpleFreezedCollectionReference._( + firestore + .collection('freezed-test') + .withConverter( + fromFirestore: SimpleFreezedCollectionReference.fromFirestore, + toFirestore: SimpleFreezedCollectionReference.toFirestore, + ), + ); + } + + _$SimpleFreezedCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + SimpleFreezedDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return SimpleFreezedDocumentReference(reference.doc(id)); + } + + @override + Future add(SimpleFreezed value) { + return reference + .add(value) + .then((ref) => SimpleFreezedDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$SimpleFreezedCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class SimpleFreezedDocumentReference + extends + FirestoreDocumentReference< + SimpleFreezed, + SimpleFreezedDocumentSnapshot + > { + factory SimpleFreezedDocumentReference( + DocumentReference reference, + ) = _$SimpleFreezedDocumentReference; + + DocumentReference get reference; + + /// A reference to the [SimpleFreezedCollectionReference] containing this document. + SimpleFreezedCollectionReference get parent { + return _$SimpleFreezedCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + SimpleFreezed model, { + SetOptions? options, + FieldValue aFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + SimpleFreezed model, { + SetOptions? options, + FieldValue aFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + SimpleFreezed model, { + SetOptions? options, + FieldValue aFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({int a, FieldValue aFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + int a, + FieldValue aFieldValue, + }); + + /// 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 a, FieldValue aFieldValue}); +} + +class _$SimpleFreezedDocumentReference + extends + FirestoreDocumentReference + implements SimpleFreezedDocumentReference { + _$SimpleFreezedDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [SimpleFreezedCollectionReference] containing this document. + SimpleFreezedCollectionReference get parent { + return _$SimpleFreezedCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(SimpleFreezedDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(SimpleFreezedDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(SimpleFreezedDocumentSnapshot._); + } + + Future set( + SimpleFreezed model, { + SetOptions? options, + FieldValue? aFieldValue, + }) async { + final json = { + ...model.toJson(), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + SimpleFreezed model, { + SetOptions? options, + FieldValue? aFieldValue, + }) { + final json = { + ...model.toJson(), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + SimpleFreezed model, { + SetOptions? options, + FieldValue? aFieldValue, + }) { + final json = { + ...model.toJson(), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({Object? a = _sentinel, FieldValue? aFieldValue}) async { + assert( + a == _sentinel || aFieldValue == null, + "Cannot specify both a and aFieldValue", + ); + final json = { + if (a != _sentinel) + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + Object? a = _sentinel, + FieldValue? aFieldValue, + }) { + assert( + a == _sentinel || aFieldValue == null, + "Cannot specify both a and aFieldValue", + ); + final json = { + if (a != _sentinel) + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + transaction.update(reference, json); + } + + void batchUpdate( + WriteBatch batch, { + Object? a = _sentinel, + FieldValue? aFieldValue, + }) { + assert( + a == _sentinel || aFieldValue == null, + "Cannot specify both a and aFieldValue", + ); + final json = { + if (a != _sentinel) + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is SimpleFreezedDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class SimpleFreezedQuery + implements QueryReference { + @override + SimpleFreezedQuery limit(int limit); + + @override + SimpleFreezedQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + SimpleFreezedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SimpleFreezedQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SimpleFreezedQuery whereA({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + SimpleFreezedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }); + + SimpleFreezedQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }); + + SimpleFreezedQuery orderByA({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }); +} + +class _$SimpleFreezedQuery + extends QueryReference + implements SimpleFreezedQuery { + _$SimpleFreezedQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + SimpleFreezedQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(SimpleFreezedQuerySnapshot._fromQuerySnapshot); + } + + @override + SimpleFreezedQuery limit(int limit) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery limitToLast(int limit) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery whereA({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$SimpleFreezedFieldMap['a']!, + isEqualTo: isEqualTo != _sentinel + ? _$SimpleFreezedPerFieldToJson.a(isEqualTo as int) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$SimpleFreezedPerFieldToJson.a(isNotEqualTo as int) + : null, + isLessThan: isLessThan != null + ? _$SimpleFreezedPerFieldToJson.a(isLessThan as int) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$SimpleFreezedPerFieldToJson.a(isLessThanOrEqualTo as int) + : null, + isGreaterThan: isGreaterThan != null + ? _$SimpleFreezedPerFieldToJson.a(isGreaterThan as int) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$SimpleFreezedPerFieldToJson.a(isGreaterThanOrEqualTo as int) + : null, + whereIn: whereIn?.map((e) => _$SimpleFreezedPerFieldToJson.a(e)), + whereNotIn: whereNotIn?.map((e) => _$SimpleFreezedPerFieldToJson.a(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SimpleFreezedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SimpleFreezedQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SimpleFreezedQuery orderByA({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SimpleFreezedDocumentSnapshot? startAtDocument, + SimpleFreezedDocumentSnapshot? endAtDocument, + SimpleFreezedDocumentSnapshot? endBeforeDocument, + SimpleFreezedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$SimpleFreezedFieldMap['a']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$SimpleFreezedPerFieldToJson.a(startAt as int), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$SimpleFreezedPerFieldToJson.a(startAfter as int), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$SimpleFreezedPerFieldToJson.a(endAt as int), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$SimpleFreezedPerFieldToJson.a(endBefore as int), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SimpleFreezedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$SimpleFreezedQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class SimpleFreezedDocumentSnapshot + extends FirestoreDocumentSnapshot { + SimpleFreezedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + SimpleFreezedDocumentReference get reference { + return SimpleFreezedDocumentReference(snapshot.reference); + } + + @override + final SimpleFreezed? data; +} + +class SimpleFreezedQuerySnapshot + extends + FirestoreQuerySnapshot< + SimpleFreezed, + SimpleFreezedQueryDocumentSnapshot + > { + SimpleFreezedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory SimpleFreezedQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(SimpleFreezedQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, SimpleFreezedDocumentSnapshot._); + }).toList(); + + return SimpleFreezedQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + SimpleFreezedDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class SimpleFreezedQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements SimpleFreezedDocumentSnapshot { + SimpleFreezedQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final SimpleFreezed data; + + @override + SimpleFreezedDocumentReference get reference { + return SimpleFreezedDocumentReference(snapshot.reference); + } +} diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart index 5c1d22c..fcfe548 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,357 +9,731 @@ part of 'freezed.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Person _$PersonFromJson(Map json) { - return _Person.fromJson(json); -} - /// @nodoc mixin _$Person { - String get firstName => throw _privateConstructorUsedError; - @JsonKey(name: 'LAST_NAME') - String get lastName => throw _privateConstructorUsedError; - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored => throw _privateConstructorUsedError; + + String get firstName;@JsonKey(name: 'LAST_NAME') String get lastName;@JsonKey(includeFromJson: false, includeToJson: false) int? get ignored; +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PersonCopyWith get copyWith => _$PersonCopyWithImpl(this as Person, _$identity); /// Serializes this Person to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PersonCopyWith get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); } -/// @nodoc -abstract class $PersonCopyWith<$Res> { - factory $PersonCopyWith(Person value, $Res Function(Person) then) = - _$PersonCopyWithImpl<$Res, Person>; - @useResult - $Res call( - {String firstName, - @JsonKey(name: 'LAST_NAME') String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) int? ignored}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; +} + + } /// @nodoc -class _$PersonCopyWithImpl<$Res, $Val extends Person> +abstract mixin class $PersonCopyWith<$Res> { + factory $PersonCopyWith(Person value, $Res Function(Person) _then) = _$PersonCopyWithImpl; +@useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); + + + + +} +/// @nodoc +class _$PersonCopyWithImpl<$Res> implements $PersonCopyWith<$Res> { - _$PersonCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? firstName = null, - Object? lastName = null, - Object? ignored = freezed, - }) { - return _then(_value.copyWith( - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - ignored: freezed == ignored - ? _value.ignored - : ignored // ignore: cast_nullable_to_non_nullable - as int?, - ) as $Val); - } + _$PersonCopyWithImpl(this._self, this._then); + + final Person _self; + final $Res Function(Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_self.copyWith( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); } -/// @nodoc -abstract class _$$PersonImplCopyWith<$Res> implements $PersonCopyWith<$Res> { - factory _$$PersonImplCopyWith( - _$PersonImpl value, $Res Function(_$PersonImpl) then) = - __$$PersonImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String firstName, - @JsonKey(name: 'LAST_NAME') String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) int? ignored}); } -/// @nodoc -class __$$PersonImplCopyWithImpl<$Res> - extends _$PersonCopyWithImpl<$Res, _$PersonImpl> - implements _$$PersonImplCopyWith<$Res> { - __$$PersonImplCopyWithImpl( - _$PersonImpl _value, $Res Function(_$PersonImpl) _then) - : super(_value, _then); - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? firstName = null, - Object? lastName = null, - Object? ignored = freezed, - }) { - return _then(_$PersonImpl( - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - ignored: freezed == ignored - ? _value.ignored - : ignored // ignore: cast_nullable_to_non_nullable - as int?, - )); - } + +/// Adds pattern-matching-related methods to [Person]. +extension PersonPatterns on Person { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Person value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Person value) $default,){ +final _that = this; +switch (_that) { +case _Person(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Person value)? $default,){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored) $default,) {final _that = this; +switch (_that) { +case _Person(): +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable(fieldRename: FieldRename.snake) -class _$PersonImpl implements _Person { - _$PersonImpl( - {required this.firstName, - @JsonKey(name: 'LAST_NAME') required this.lastName, - @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); - - factory _$PersonImpl.fromJson(Map json) => - _$$PersonImplFromJson(json); - - @override - final String firstName; - @override - @JsonKey(name: 'LAST_NAME') - final String lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - final int? ignored; - - @override - String toString() { - return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PersonImpl && - (identical(other.firstName, firstName) || - other.firstName == firstName) && - (identical(other.lastName, lastName) || - other.lastName == lastName) && - (identical(other.ignored, ignored) || other.ignored == ignored)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, firstName, lastName, ignored); - - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - __$$PersonImplCopyWithImpl<_$PersonImpl>(this, _$identity); - - @override - Map toJson() { - return _$$PersonImplToJson( - this, - ); - } +class _Person implements Person { + _Person({required this.firstName, @JsonKey(name: 'LAST_NAME') required this.lastName, @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); + factory _Person.fromJson(Map json) => _$PersonFromJson(json); + +@override final String firstName; +@override@JsonKey(name: 'LAST_NAME') final String lastName; +@override@JsonKey(includeFromJson: false, includeToJson: false) final int? ignored; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PersonCopyWith<_Person> get copyWith => __$PersonCopyWithImpl<_Person>(this, _$identity); + +@override +Map toJson() { + return _$PersonToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; } -abstract class _Person implements Person { - factory _Person( - {required final String firstName, - @JsonKey(name: 'LAST_NAME') required final String lastName, - @JsonKey(includeFromJson: false, includeToJson: false) - final int? ignored}) = _$PersonImpl; - factory _Person.fromJson(Map json) = _$PersonImpl.fromJson; +} + +/// @nodoc +abstract mixin class _$PersonCopyWith<$Res> implements $PersonCopyWith<$Res> { + factory _$PersonCopyWith(_Person value, $Res Function(_Person) _then) = __$PersonCopyWithImpl; +@override @useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); + + + + +} +/// @nodoc +class __$PersonCopyWithImpl<$Res> + implements _$PersonCopyWith<$Res> { + __$PersonCopyWithImpl(this._self, this._then); + + final _Person _self; + final $Res Function(_Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_Person( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); +} - @override - String get firstName; - @override - @JsonKey(name: 'LAST_NAME') - String get lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored; - /// Create a copy of Person - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - throw _privateConstructorUsedError; } -PublicRedirected _$PublicRedirectedFromJson(Map json) { - return PublicRedirected2.fromJson(json); +PublicRedirected _$PublicRedirectedFromJson( + Map json +) { + return PublicRedirected2.fromJson( + json + ); } /// @nodoc mixin _$PublicRedirected { - String get value => throw _privateConstructorUsedError; + + String get value; +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirectedCopyWith get copyWith => _$PublicRedirectedCopyWithImpl(this as PublicRedirected, _$identity); /// Serializes this PublicRedirected to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $PublicRedirectedCopyWith get copyWith => - throw _privateConstructorUsedError; + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected&&(identical(other.value, value) || other.value == value)); } -/// @nodoc -abstract class $PublicRedirectedCopyWith<$Res> { - factory $PublicRedirectedCopyWith( - PublicRedirected value, $Res Function(PublicRedirected) then) = - _$PublicRedirectedCopyWithImpl<$Res, PublicRedirected>; - @useResult - $Res call({String value}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString() { + return 'PublicRedirected(value: $value)'; } + +} + +/// @nodoc +abstract mixin class $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirectedCopyWith(PublicRedirected value, $Res Function(PublicRedirected) _then) = _$PublicRedirectedCopyWithImpl; +@useResult +$Res call({ + String value +}); + + + + +} /// @nodoc -class _$PublicRedirectedCopyWithImpl<$Res, $Val extends PublicRedirected> +class _$PublicRedirectedCopyWithImpl<$Res> implements $PublicRedirectedCopyWith<$Res> { - _$PublicRedirectedCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = null, - }) { - return _then(_value.copyWith( - value: null == value - ? _value.value - : value // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } + _$PublicRedirectedCopyWithImpl(this._self, this._then); + + final PublicRedirected _self; + final $Res Function(PublicRedirected) _then; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? value = null,}) { + return _then(_self.copyWith( +value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as String, + )); +} + +} + + +/// Adds pattern-matching-related methods to [PublicRedirected]. +extension PublicRedirectedPatterns on PublicRedirected { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( PublicRedirected2 value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( PublicRedirected2 value) $default,){ +final _that = this; +switch (_that) { +case PublicRedirected2(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( PublicRedirected2 value)? $default,){ +final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String value)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that.value);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String value) $default,) {final _that = this; +switch (_that) { +case PublicRedirected2(): +return $default(_that.value);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String value)? $default,) {final _that = this; +switch (_that) { +case PublicRedirected2() when $default != null: +return $default(_that.value);case _: + return null; + +} +} + } /// @nodoc -abstract class _$$PublicRedirected2ImplCopyWith<$Res> - implements $PublicRedirectedCopyWith<$Res> { - factory _$$PublicRedirected2ImplCopyWith(_$PublicRedirected2Impl value, - $Res Function(_$PublicRedirected2Impl) then) = - __$$PublicRedirected2ImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String value}); +@JsonSerializable() + +class PublicRedirected2 implements PublicRedirected { + PublicRedirected2({required this.value}); + factory PublicRedirected2.fromJson(Map json) => _$PublicRedirected2FromJson(json); + +@override final String value; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirected2CopyWith get copyWith => _$PublicRedirected2CopyWithImpl(this, _$identity); + +@override +Map toJson() { + return _$PublicRedirected2ToJson(this, ); } +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected2&&(identical(other.value, value) || other.value == value)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,value); + +@override +String toString() { + return 'PublicRedirected(value: $value)'; +} + + +} + +/// @nodoc +abstract mixin class $PublicRedirected2CopyWith<$Res> implements $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirected2CopyWith(PublicRedirected2 value, $Res Function(PublicRedirected2) _then) = _$PublicRedirected2CopyWithImpl; +@override @useResult +$Res call({ + String value +}); + + + + +} /// @nodoc -class __$$PublicRedirected2ImplCopyWithImpl<$Res> - extends _$PublicRedirectedCopyWithImpl<$Res, _$PublicRedirected2Impl> - implements _$$PublicRedirected2ImplCopyWith<$Res> { - __$$PublicRedirected2ImplCopyWithImpl(_$PublicRedirected2Impl _value, - $Res Function(_$PublicRedirected2Impl) _then) - : super(_value, _then); - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? value = null, - }) { - return _then(_$PublicRedirected2Impl( - value: null == value - ? _value.value - : value // ignore: cast_nullable_to_non_nullable - as String, - )); - } +class _$PublicRedirected2CopyWithImpl<$Res> + implements $PublicRedirected2CopyWith<$Res> { + _$PublicRedirected2CopyWithImpl(this._self, this._then); + + final PublicRedirected2 _self; + final $Res Function(PublicRedirected2) _then; + +/// Create a copy of PublicRedirected +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? value = null,}) { + return _then(PublicRedirected2( +value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable +as String, + )); +} + + } + /// @nodoc -@JsonSerializable() -class _$PublicRedirected2Impl implements PublicRedirected2 { - _$PublicRedirected2Impl({required this.value}); - - factory _$PublicRedirected2Impl.fromJson(Map json) => - _$$PublicRedirected2ImplFromJson(json); - - @override - final String value; - - @override - String toString() { - return 'PublicRedirected(value: $value)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$PublicRedirected2Impl && - (identical(other.value, value) || other.value == value)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, value); - - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - __$$PublicRedirected2ImplCopyWithImpl<_$PublicRedirected2Impl>( - this, _$identity); - - @override - Map toJson() { - return _$$PublicRedirected2ImplToJson( - this, - ); - } +mixin _$SimpleFreezed { + + int get a; +/// Create a copy of SimpleFreezed +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SimpleFreezedCopyWith get copyWith => _$SimpleFreezedCopyWithImpl(this as SimpleFreezed, _$identity); + + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SimpleFreezed&&(identical(other.a, a) || other.a == a)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,a); + +@override +String toString() { + return 'SimpleFreezed(a: $a)'; +} + + } -abstract class PublicRedirected2 implements PublicRedirected { - factory PublicRedirected2({required final String value}) = - _$PublicRedirected2Impl; +/// @nodoc +abstract mixin class $SimpleFreezedCopyWith<$Res> { + factory $SimpleFreezedCopyWith(SimpleFreezed value, $Res Function(SimpleFreezed) _then) = _$SimpleFreezedCopyWithImpl; +@useResult +$Res call({ + int a +}); + + + + +} +/// @nodoc +class _$SimpleFreezedCopyWithImpl<$Res> + implements $SimpleFreezedCopyWith<$Res> { + _$SimpleFreezedCopyWithImpl(this._self, this._then); + + final SimpleFreezed _self; + final $Res Function(SimpleFreezed) _then; + +/// Create a copy of SimpleFreezed +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? a = null,}) { + return _then(SimpleFreezed( +a: null == a ? _self.a : a // ignore: cast_nullable_to_non_nullable +as int, + )); +} + +} - factory PublicRedirected2.fromJson(Map json) = - _$PublicRedirected2Impl.fromJson; - @override - String get value; +/// Adds pattern-matching-related methods to [SimpleFreezed]. +extension SimpleFreezedPatterns on SimpleFreezed { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap({required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _: + return orElse(); - /// Create a copy of PublicRedirected - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - throw _privateConstructorUsedError; } +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(){ +final _that = this; +switch (_that) { +case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(){ +final _that = this; +switch (_that) { +case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen({required TResult orElse(),}) {final _that = this; +switch (_that) { +case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when() {final _that = this; +switch (_that) { +case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull() {final _that = this; +switch (_that) { +case _: + return null; + +} +} + +} + +// dart format on 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 7ca05a2..2c6cd09 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 @@ -3,2115 +3,56 @@ part of 'freezed.dart'; // ************************************************************************** -// CollectionGenerator +// JsonSerializableGenerator // ************************************************************************** -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore -// ignore_for_file: type=lint -// ignore_for_file: invalid_use_of_internal_member - -class _Sentinel { - const _Sentinel(); -} - -const _sentinel = _Sentinel(); - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class PersonCollectionReference - implements - PersonQuery, - FirestoreCollectionReference { - factory PersonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PersonCollectionReference; - - static Person fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return Person.fromJson(snapshot.data()!); - } - - static Map toFirestore( - Person value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - PersonDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Person value); -} - -class _$PersonCollectionReference extends _$PersonQuery - implements PersonCollectionReference { - factory _$PersonCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$PersonCollectionReference._( - firestore.collection('freezed-test').withConverter( - fromFirestore: PersonCollectionReference.fromFirestore, - toFirestore: PersonCollectionReference.toFirestore, - ), - ); - } - - _$PersonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - PersonDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return PersonDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Person value) { - return reference.add(value).then((ref) => PersonDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$PersonCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class PersonDocumentReference - extends FirestoreDocumentReference { - factory PersonDocumentReference(DocumentReference reference) = - _$PersonDocumentReference; - - DocumentReference get reference; - - /// A reference to the [PersonCollectionReference] containing this document. - PersonCollectionReference get parent { - return _$PersonCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Person model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Person model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Person model, { - SetOptions? options, - FieldValue firstNameFieldValue, - FieldValue lastNameFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String firstName, - FieldValue firstNameFieldValue, - String lastName, - FieldValue lastNameFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - String firstName, - FieldValue firstNameFieldValue, - 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 - extends FirestoreDocumentReference - implements PersonDocumentReference { - _$PersonDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [PersonCollectionReference] containing this document. - PersonCollectionReference get parent { - return _$PersonCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(PersonDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(PersonDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(PersonDocumentSnapshot._); - } - - Future set( - Person model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) async { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Person model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Person model, { - SetOptions? options, - FieldValue? firstNameFieldValue, - FieldValue? lastNameFieldValue, - }) { - final json = { - ...model.toJson(), - if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, - if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? firstName = _sentinel, - FieldValue? firstNameFieldValue, - Object? lastName = _sentinel, - FieldValue? lastNameFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class PersonQuery - implements QueryReference { - @override - PersonQuery limit(int limit); - - @override - PersonQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - PersonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PersonQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PersonQuery whereFirstName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PersonQuery whereLastName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - PersonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }); - - PersonQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }); - - PersonQuery orderByFirstName({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }); - - PersonQuery orderByLastName({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }); -} - -class _$PersonQuery extends QueryReference - implements PersonQuery { - _$PersonQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(PersonQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(PersonQuerySnapshot._fromQuerySnapshot); - } - - @override - PersonQuery limit(int limit) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery limitToLast(int limit) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery whereFirstName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['firstName']!, - isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.firstName(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.firstName(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery whereLastName({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PersonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['lastName']!, - isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.lastName(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.lastName(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PersonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PersonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PersonQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PersonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PersonQuery orderByFirstName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['firstName']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PersonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PersonQuery orderByLastName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PersonDocumentSnapshot? startAtDocument, - PersonDocumentSnapshot? endAtDocument, - PersonDocumentSnapshot? endBeforeDocument, - PersonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['lastName']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PersonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$PersonQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { - PersonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - PersonDocumentReference get reference { - return PersonDocumentReference( - snapshot.reference, - ); - } - - @override - final Person? data; -} - -class PersonQuerySnapshot - extends FirestoreQuerySnapshot { - PersonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory PersonQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PersonDocumentSnapshot._, - ); - }).toList(); - - return PersonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements PersonDocumentSnapshot { - PersonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); +SimpleFreezed _$SimpleFreezedFromJson(Map json) => + SimpleFreezed(a: (json['a'] as num).toInt()); - @override - final QueryDocumentSnapshot snapshot; +const _$SimpleFreezedFieldMap = {'a': 'a'}; - @override - final Person data; - - @override - PersonDocumentReference get reference { - return PersonDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class PublicRedirectedCollectionReference - implements - PublicRedirectedQuery, - FirestoreCollectionReference { - factory PublicRedirectedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PublicRedirectedCollectionReference; - - static PublicRedirected fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return PublicRedirected.fromJson(snapshot.data()!); - } - - static Map toFirestore( - PublicRedirected value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - PublicRedirectedDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(PublicRedirected value); -} - -class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery - implements PublicRedirectedCollectionReference { - factory _$PublicRedirectedCollectionReference( - [FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$PublicRedirectedCollectionReference._( - firestore.collection('freezed-test').withConverter( - fromFirestore: PublicRedirectedCollectionReference.fromFirestore, - toFirestore: PublicRedirectedCollectionReference.toFirestore, - ), - ); - } - - _$PublicRedirectedCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - PublicRedirectedDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return PublicRedirectedDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(PublicRedirected value) { - return reference - .add(value) - .then((ref) => PublicRedirectedDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$PublicRedirectedCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class PublicRedirectedDocumentReference - extends FirestoreDocumentReference { - factory PublicRedirectedDocumentReference( - DocumentReference reference) = - _$PublicRedirectedDocumentReference; - - DocumentReference get reference; - - /// A reference to the [PublicRedirectedCollectionReference] containing this document. - PublicRedirectedCollectionReference get parent { - return _$PublicRedirectedCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - PublicRedirected model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - PublicRedirected model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - PublicRedirected model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - PublicRedirected, PublicRedirectedDocumentSnapshot> - implements PublicRedirectedDocumentReference { - _$PublicRedirectedDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [PublicRedirectedCollectionReference] containing this document. - PublicRedirectedCollectionReference get parent { - return _$PublicRedirectedCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(PublicRedirectedDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(PublicRedirectedDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); - } - - Future set( - PublicRedirected model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - PublicRedirected model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - PublicRedirected model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class PublicRedirectedQuery - implements QueryReference { - @override - PublicRedirectedQuery limit(int limit); - - @override - PublicRedirectedQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - PublicRedirectedQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PublicRedirectedQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - PublicRedirectedQuery whereValue({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - PublicRedirectedQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }); - - PublicRedirectedQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }); - - PublicRedirectedQuery orderByValue({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }); -} - -class _$PublicRedirectedQuery - extends QueryReference - implements PublicRedirectedQuery { - _$PublicRedirectedQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(PublicRedirectedQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(PublicRedirectedQuerySnapshot._fromQuerySnapshot); - } - - @override - PublicRedirectedQuery limit(int limit) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery limitToLast(int limit) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PublicRedirected2ImplFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson.value(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$$PublicRedirected2ImplPerFieldToJson.value(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - whereNotIn: whereNotIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - PublicRedirectedQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PublicRedirectedQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - PublicRedirectedQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - PublicRedirectedDocumentSnapshot? startAtDocument, - PublicRedirectedDocumentSnapshot? endAtDocument, - PublicRedirectedDocumentSnapshot? endBeforeDocument, - PublicRedirectedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy( - _$$PublicRedirected2ImplFieldMap['value']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PublicRedirectedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$PublicRedirectedQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class PublicRedirectedDocumentSnapshot - extends FirestoreDocumentSnapshot { - PublicRedirectedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference( - snapshot.reference, - ); - } - - @override - final PublicRedirected? data; -} - -class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< - PublicRedirected, PublicRedirectedQueryDocumentSnapshot> { - PublicRedirectedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory PublicRedirectedQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(PublicRedirectedQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PublicRedirectedDocumentSnapshot._, - ); - }).toList(); - - return PublicRedirectedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> - docChanges; -} - -class PublicRedirectedQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements PublicRedirectedDocumentSnapshot { - PublicRedirectedQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final PublicRedirected data; - - @override - PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference(snapshot.reference); - } +// ignore: unused_element +abstract class _$SimpleFreezedPerFieldToJson { + // ignore: unused_element + static Object? a(int instance) => instance; } -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** +Map _$SimpleFreezedToJson(SimpleFreezed instance) => + {'a': instance.a}; -_$PersonImpl _$$PersonImplFromJson(Map json) => _$PersonImpl( - firstName: json['first_name'] as String, - lastName: json['LAST_NAME'] as String, - ); +_Person _$PersonFromJson(Map json) => _Person( + firstName: json['first_name'] as String, + lastName: json['LAST_NAME'] as String, +); -const _$$PersonImplFieldMap = { +const _$PersonFieldMap = { 'firstName': 'first_name', 'lastName': 'LAST_NAME', }; // ignore: unused_element -abstract class _$$PersonImplPerFieldToJson { +abstract class _$PersonPerFieldToJson { // ignore: unused_element static Object? firstName(String instance) => instance; // ignore: unused_element static Object? lastName(String instance) => instance; } -Map _$$PersonImplToJson(_$PersonImpl instance) => - { - 'first_name': instance.firstName, - 'LAST_NAME': instance.lastName, - }; +Map _$PersonToJson(_Person instance) => { + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; -_$PublicRedirected2Impl _$$PublicRedirected2ImplFromJson( - Map json) => - _$PublicRedirected2Impl( - value: json['value'] as String, - ); +PublicRedirected2 _$PublicRedirected2FromJson(Map json) => + PublicRedirected2(value: json['value'] as String); -const _$$PublicRedirected2ImplFieldMap = { - 'value': 'value', -}; +const _$PublicRedirected2FieldMap = {'value': 'value'}; // ignore: unused_element -abstract class _$$PublicRedirected2ImplPerFieldToJson { +abstract class _$PublicRedirected2PerFieldToJson { // ignore: unused_element static Object? value(String instance) => instance; } -Map _$$PublicRedirected2ImplToJson( - _$PublicRedirected2Impl instance) => - { - 'value': instance.value, - }; +Map _$PublicRedirected2ToJson(PublicRedirected2 instance) => + {'value': instance.value}; diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.dart new file mode 100644 index 0000000..91e75d3 --- /dev/null +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.dart @@ -0,0 +1,162 @@ +// Copyright 2022, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// ignore_for_file: invalid_annotation_target + +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:riverpod_annotation/riverpod_annotation.dart'; + +part 'riverpod_integration.firebase.dart'; +part 'riverpod_integration.freezed.dart'; +part 'riverpod_integration.g.dart'; + +const firestoreSerializable = JsonSerializable( + converters: firestoreJsonConverters, + // The following values could alternatively be set inside your `build.yaml` + explicitToJson: true, + createFieldMap: true, + createPerFieldToJson: true, +); + +/// A model that will be used with both Cloud Firestore ODM and Riverpod +@firestoreSerializable +class UserProfile { + const UserProfile({required this.id, required this.name, required this.email, this.age}); + + factory UserProfile.fromJson(Map json) => _$UserProfileFromJson(json); + + final String id; + final String name; + final String email; + final int? age; + + Map toJson() => _$UserProfileToJson(this); +} + +/// Another Firestore sub-model that will coexist with Riverpod providers +@firestoreSerializable +class Post { + const Post({ + required this.id, + required this.title, + required this.content, + required this.authorId, + required this.createdAt, + }); + + factory Post.fromJson(Map json) => _$PostFromJson(json); + + final String id; + final String title; + final String content; + final String authorId; + final DateTime createdAt; + + Map toJson() => _$PostToJson(this); +} + +/// A simple data model for testing Riverpod providers +@JsonSerializable() +class AppSettings { + const AppSettings({required this.theme, required this.notifications}); + + factory AppSettings.fromJson(Map json) => _$AppSettingsFromJson(json); + + final String theme; + final bool notifications; + + Map toJson() => _$AppSettingsToJson(this); + + AppSettings copyWith({String? theme, bool? notifications}) { + return AppSettings( + theme: theme ?? this.theme, + notifications: notifications ?? this.notifications, + ); + } +} + +/// Collection reference for Firestore ODM +@Collection('user-profiles') +@Collection('user-profiles/*/posts') +final userProfileRef = UserProfileCollectionReference(); + +@freezed +abstract class Person with _$Person { + @JsonSerializable(fieldRename: FieldRename.snake) + factory Person({ + required String firstName, + @JsonKey(name: 'LAST_NAME') required String lastName, + @JsonKey(includeFromJson: false, includeToJson: false) int? ignored, + }) = _Person; + + factory Person.fromJson(Map json) => _$PersonFromJson(json); +} + +/// Riverpod provider for user profiles collection +@riverpod +_$Person userProfilesCollection(Ref ref) { + return Person(firstName: 'John', lastName: 'Doe', ignored: 1); +} + +void main() { + print('userProfileRef: ${_$Person} - ${userProfilesCollectionProvider}'); +} + +/// Riverpod provider for a specific user profile +@riverpod +Stream userProfile(Ref ref, String userId) { + // final collection = ref.watch(userProfilesCollectionProvider); + return userProfileRef.doc(userId).snapshots().map((snapshot) { + return snapshot.data; + }); +} + +/// Riverpod provider for all user profiles +@riverpod +Stream> allUserProfiles(Ref ref) { + // final collection = ref.watch(userProfilesCollectionProvider); + return userProfileRef.reference.snapshots().map((snapshot) { + return snapshot.docs.map((doc) => doc.data()).toList(); + }); +} + +/// Riverpod provider for posts by author +@riverpod +Stream> postsByAuthor(Ref ref, String authorId) { + final collection = userProfileRef.doc(authorId).posts; + return collection + .whereAuthorId(isEqualTo: authorId) + .snapshots() + .map((snapshot) => snapshot.docs.map((doc) => doc.data).toList()); +} + +/// Riverpod provider for recent posts +@riverpod +Stream> recentPosts(Ref ref, String authorId) { + final collection = userProfileRef.doc(authorId).posts; + return collection + .orderByCreatedAt(descending: true) + .limit(10) + .snapshots() + .map((snapshot) => snapshot.docs.map((doc) => doc.data).toList()); +} + +/// Riverpod provider for app settings +@riverpod +class AppSettingsNotifier extends _$AppSettingsNotifier { + @override + AppSettings build() { + return const AppSettings(theme: 'light', notifications: true); + } + + void updateTheme(String theme) { + state = state.copyWith(theme: theme); + } + + void toggleNotifications() { + state = state.copyWith(notifications: !state.notifications); + } +} diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.firebase.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.firebase.dart new file mode 100644 index 0000000..69e824b --- /dev/null +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.firebase.dart @@ -0,0 +1,3411 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'riverpod_integration.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class UserProfileCollectionReference + implements + UserProfileQuery, + FirestoreCollectionReference { + factory UserProfileCollectionReference([FirebaseFirestore? firestore]) = + _$UserProfileCollectionReference; + + static UserProfile fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return UserProfile.fromJson(snapshot.data()!); + } + + static Map toFirestore( + UserProfile value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + UserProfileDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(UserProfile value); +} + +class _$UserProfileCollectionReference extends _$UserProfileQuery + implements UserProfileCollectionReference { + factory _$UserProfileCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$UserProfileCollectionReference._( + firestore + .collection('user-profiles') + .withConverter( + fromFirestore: UserProfileCollectionReference.fromFirestore, + toFirestore: UserProfileCollectionReference.toFirestore, + ), + ); + } + + _$UserProfileCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + UserProfileDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return UserProfileDocumentReference(reference.doc(id)); + } + + @override + Future add(UserProfile value) { + return reference + .add(value) + .then((ref) => UserProfileDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$UserProfileCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class UserProfileDocumentReference + extends + FirestoreDocumentReference { + factory UserProfileDocumentReference( + DocumentReference reference, + ) = _$UserProfileDocumentReference; + + DocumentReference get reference; + + /// A reference to the [UserProfileCollectionReference] containing this document. + UserProfileCollectionReference get parent { + return _$UserProfileCollectionReference(reference.firestore); + } + + late final PostCollectionReference posts = _$PostCollectionReference( + reference, + ); + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + UserProfile model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue nameFieldValue, + FieldValue emailFieldValue, + FieldValue ageFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + UserProfile model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue nameFieldValue, + FieldValue emailFieldValue, + FieldValue ageFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + UserProfile model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue nameFieldValue, + FieldValue emailFieldValue, + FieldValue ageFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String id, + FieldValue idFieldValue, + String name, + FieldValue nameFieldValue, + String email, + FieldValue emailFieldValue, + int? age, + FieldValue ageFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String id, + FieldValue idFieldValue, + String name, + FieldValue nameFieldValue, + String email, + FieldValue emailFieldValue, + int? age, + FieldValue ageFieldValue, + }); + + /// 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, + String name, + FieldValue nameFieldValue, + String email, + FieldValue emailFieldValue, + int? age, + FieldValue ageFieldValue, + }); +} + +class _$UserProfileDocumentReference + extends FirestoreDocumentReference + implements UserProfileDocumentReference { + _$UserProfileDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [UserProfileCollectionReference] containing this document. + UserProfileCollectionReference get parent { + return _$UserProfileCollectionReference(reference.firestore); + } + + late final PostCollectionReference posts = _$PostCollectionReference( + reference, + ); + + @override + Stream snapshots() { + return reference.snapshots().map(UserProfileDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(UserProfileDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(UserProfileDocumentSnapshot._); + } + + Future set( + UserProfile model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? nameFieldValue, + FieldValue? emailFieldValue, + FieldValue? ageFieldValue, + }) async { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$UserProfileFieldMap['id']!: idFieldValue, + + if (nameFieldValue != null) + _$UserProfileFieldMap['name']!: nameFieldValue, + + if (emailFieldValue != null) + _$UserProfileFieldMap['email']!: emailFieldValue, + + if (ageFieldValue != null) _$UserProfileFieldMap['age']!: ageFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + UserProfile model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? nameFieldValue, + FieldValue? emailFieldValue, + FieldValue? ageFieldValue, + }) { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$UserProfileFieldMap['id']!: idFieldValue, + + if (nameFieldValue != null) + _$UserProfileFieldMap['name']!: nameFieldValue, + + if (emailFieldValue != null) + _$UserProfileFieldMap['email']!: emailFieldValue, + + if (ageFieldValue != null) _$UserProfileFieldMap['age']!: ageFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + UserProfile model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? nameFieldValue, + FieldValue? emailFieldValue, + FieldValue? ageFieldValue, + }) { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$UserProfileFieldMap['id']!: idFieldValue, + + if (nameFieldValue != null) + _$UserProfileFieldMap['name']!: nameFieldValue, + + if (emailFieldValue != null) + _$UserProfileFieldMap['email']!: emailFieldValue, + + if (ageFieldValue != null) _$UserProfileFieldMap['age']!: ageFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? id = _sentinel, + FieldValue? idFieldValue, + Object? name = _sentinel, + FieldValue? nameFieldValue, + Object? email = _sentinel, + FieldValue? emailFieldValue, + Object? age = _sentinel, + FieldValue? ageFieldValue, + }) async { + assert( + id == _sentinel || idFieldValue == null, + "Cannot specify both id and idFieldValue", + ); + assert( + name == _sentinel || nameFieldValue == null, + "Cannot specify both name and nameFieldValue", + ); + assert( + email == _sentinel || emailFieldValue == null, + "Cannot specify both email and emailFieldValue", + ); + assert( + age == _sentinel || ageFieldValue == null, + "Cannot specify both age and ageFieldValue", + ); + final json = { + if (id != _sentinel) + _$UserProfileFieldMap['id']!: _$UserProfilePerFieldToJson.id( + id as String, + ), + + if (idFieldValue != null) _$UserProfileFieldMap['id']!: idFieldValue, + + if (name != _sentinel) + _$UserProfileFieldMap['name']!: _$UserProfilePerFieldToJson.name( + name as String, + ), + + if (nameFieldValue != null) + _$UserProfileFieldMap['name']!: nameFieldValue, + + if (email != _sentinel) + _$UserProfileFieldMap['email']!: _$UserProfilePerFieldToJson.email( + email as String, + ), + + if (emailFieldValue != null) + _$UserProfileFieldMap['email']!: emailFieldValue, + + if (age != _sentinel) + _$UserProfileFieldMap['age']!: _$UserProfilePerFieldToJson.age( + age as int?, + ), + + if (ageFieldValue != null) _$UserProfileFieldMap['age']!: ageFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + Object? id = _sentinel, + FieldValue? idFieldValue, + Object? name = _sentinel, + FieldValue? nameFieldValue, + Object? email = _sentinel, + FieldValue? emailFieldValue, + Object? age = _sentinel, + FieldValue? ageFieldValue, + }) { + assert( + id == _sentinel || idFieldValue == null, + "Cannot specify both id and idFieldValue", + ); + assert( + name == _sentinel || nameFieldValue == null, + "Cannot specify both name and nameFieldValue", + ); + assert( + email == _sentinel || emailFieldValue == null, + "Cannot specify both email and emailFieldValue", + ); + assert( + age == _sentinel || ageFieldValue == null, + "Cannot specify both age and ageFieldValue", + ); + final json = { + if (id != _sentinel) + _$UserProfileFieldMap['id']!: _$UserProfilePerFieldToJson.id( + id as String, + ), + + if (idFieldValue != null) _$UserProfileFieldMap['id']!: idFieldValue, + + if (name != _sentinel) + _$UserProfileFieldMap['name']!: _$UserProfilePerFieldToJson.name( + name as String, + ), + + if (nameFieldValue != null) + _$UserProfileFieldMap['name']!: nameFieldValue, + + if (email != _sentinel) + _$UserProfileFieldMap['email']!: _$UserProfilePerFieldToJson.email( + email as String, + ), + + if (emailFieldValue != null) + _$UserProfileFieldMap['email']!: emailFieldValue, + + if (age != _sentinel) + _$UserProfileFieldMap['age']!: _$UserProfilePerFieldToJson.age( + age as int?, + ), + + if (ageFieldValue != null) _$UserProfileFieldMap['age']!: ageFieldValue, + }; + + transaction.update(reference, json); + } + + void batchUpdate( + WriteBatch batch, { + Object? id = _sentinel, + FieldValue? idFieldValue, + Object? name = _sentinel, + FieldValue? nameFieldValue, + Object? email = _sentinel, + FieldValue? emailFieldValue, + Object? age = _sentinel, + FieldValue? ageFieldValue, + }) { + assert( + id == _sentinel || idFieldValue == null, + "Cannot specify both id and idFieldValue", + ); + assert( + name == _sentinel || nameFieldValue == null, + "Cannot specify both name and nameFieldValue", + ); + assert( + email == _sentinel || emailFieldValue == null, + "Cannot specify both email and emailFieldValue", + ); + assert( + age == _sentinel || ageFieldValue == null, + "Cannot specify both age and ageFieldValue", + ); + final json = { + if (id != _sentinel) + _$UserProfileFieldMap['id']!: _$UserProfilePerFieldToJson.id( + id as String, + ), + + if (idFieldValue != null) _$UserProfileFieldMap['id']!: idFieldValue, + + if (name != _sentinel) + _$UserProfileFieldMap['name']!: _$UserProfilePerFieldToJson.name( + name as String, + ), + + if (nameFieldValue != null) + _$UserProfileFieldMap['name']!: nameFieldValue, + + if (email != _sentinel) + _$UserProfileFieldMap['email']!: _$UserProfilePerFieldToJson.email( + email as String, + ), + + if (emailFieldValue != null) + _$UserProfileFieldMap['email']!: emailFieldValue, + + if (age != _sentinel) + _$UserProfileFieldMap['age']!: _$UserProfilePerFieldToJson.age( + age as int?, + ), + + if (ageFieldValue != null) _$UserProfileFieldMap['age']!: ageFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is UserProfileDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class UserProfileQuery + implements QueryReference { + @override + UserProfileQuery limit(int limit); + + @override + UserProfileQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + UserProfileQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + UserProfileQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + UserProfileQuery whereId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + UserProfileQuery whereName({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + UserProfileQuery whereEmail({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + UserProfileQuery whereAge({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + UserProfileQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }); + + UserProfileQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }); + + UserProfileQuery orderById({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }); + + UserProfileQuery orderByName({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }); + + UserProfileQuery orderByEmail({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }); + + UserProfileQuery orderByAge({ + bool descending = false, + int? startAt, + int? startAfter, + int? endAt, + int? endBefore, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }); +} + +class _$UserProfileQuery + extends QueryReference + implements UserProfileQuery { + _$UserProfileQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + UserProfileQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(UserProfileQuerySnapshot._fromQuerySnapshot); + } + + @override + UserProfileQuery limit(int limit) { + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + UserProfileQuery limitToLast(int limit) { + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + UserProfileQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + UserProfileQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + UserProfileQuery whereId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$UserProfileFieldMap['id']!, + isEqualTo: isEqualTo != _sentinel + ? _$UserProfilePerFieldToJson.id(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$UserProfilePerFieldToJson.id(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$UserProfilePerFieldToJson.id(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$UserProfilePerFieldToJson.id(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$UserProfilePerFieldToJson.id(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$UserProfilePerFieldToJson.id(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$UserProfilePerFieldToJson.id(e)), + whereNotIn: whereNotIn?.map((e) => _$UserProfilePerFieldToJson.id(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + UserProfileQuery whereName({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$UserProfileFieldMap['name']!, + isEqualTo: isEqualTo != _sentinel + ? _$UserProfilePerFieldToJson.name(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$UserProfilePerFieldToJson.name(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$UserProfilePerFieldToJson.name(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$UserProfilePerFieldToJson.name(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$UserProfilePerFieldToJson.name(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$UserProfilePerFieldToJson.name(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$UserProfilePerFieldToJson.name(e)), + whereNotIn: whereNotIn?.map((e) => _$UserProfilePerFieldToJson.name(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + UserProfileQuery whereEmail({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$UserProfileFieldMap['email']!, + isEqualTo: isEqualTo != _sentinel + ? _$UserProfilePerFieldToJson.email(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$UserProfilePerFieldToJson.email(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$UserProfilePerFieldToJson.email(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$UserProfilePerFieldToJson.email(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$UserProfilePerFieldToJson.email(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$UserProfilePerFieldToJson.email( + isGreaterThanOrEqualTo as String, + ) + : null, + whereIn: whereIn?.map((e) => _$UserProfilePerFieldToJson.email(e)), + whereNotIn: whereNotIn?.map( + (e) => _$UserProfilePerFieldToJson.email(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + UserProfileQuery whereAge({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$UserProfileFieldMap['age']!, + isEqualTo: isEqualTo != _sentinel + ? _$UserProfilePerFieldToJson.age(isEqualTo as int?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$UserProfilePerFieldToJson.age(isNotEqualTo as int?) + : null, + isLessThan: isLessThan != null + ? _$UserProfilePerFieldToJson.age(isLessThan as int?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$UserProfilePerFieldToJson.age(isLessThanOrEqualTo as int?) + : null, + isGreaterThan: isGreaterThan != null + ? _$UserProfilePerFieldToJson.age(isGreaterThan as int?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$UserProfilePerFieldToJson.age(isGreaterThanOrEqualTo as int?) + : null, + whereIn: whereIn?.map((e) => _$UserProfilePerFieldToJson.age(e)), + whereNotIn: whereNotIn?.map((e) => _$UserProfilePerFieldToJson.age(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + UserProfileQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + UserProfileQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + UserProfileQuery orderById({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$UserProfileFieldMap['id']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$UserProfilePerFieldToJson.id(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$UserProfilePerFieldToJson.id(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$UserProfilePerFieldToJson.id(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$UserProfilePerFieldToJson.id(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + UserProfileQuery orderByName({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$UserProfileFieldMap['name']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$UserProfilePerFieldToJson.name(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$UserProfilePerFieldToJson.name(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$UserProfilePerFieldToJson.name(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$UserProfilePerFieldToJson.name(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + UserProfileQuery orderByEmail({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$UserProfileFieldMap['email']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$UserProfilePerFieldToJson.email(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$UserProfilePerFieldToJson.email(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$UserProfilePerFieldToJson.email(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$UserProfilePerFieldToJson.email(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + UserProfileQuery orderByAge({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + UserProfileDocumentSnapshot? startAtDocument, + UserProfileDocumentSnapshot? endAtDocument, + UserProfileDocumentSnapshot? endBeforeDocument, + UserProfileDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$UserProfileFieldMap['age']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$UserProfilePerFieldToJson.age(startAt as int?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$UserProfilePerFieldToJson.age(startAfter as int?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$UserProfilePerFieldToJson.age(endAt as int?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$UserProfilePerFieldToJson.age(endBefore as int?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$UserProfileQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$UserProfileQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class UserProfileDocumentSnapshot + extends FirestoreDocumentSnapshot { + UserProfileDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + UserProfileDocumentReference get reference { + return UserProfileDocumentReference(snapshot.reference); + } + + @override + final UserProfile? data; +} + +class UserProfileQuerySnapshot + extends + FirestoreQuerySnapshot { + UserProfileQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory UserProfileQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(UserProfileQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, UserProfileDocumentSnapshot._); + }).toList(); + + return UserProfileQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + UserProfileDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class UserProfileQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements UserProfileDocumentSnapshot { + UserProfileQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final UserProfile data; + + @override + UserProfileDocumentReference get reference { + return UserProfileDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class PostCollectionReference + implements + PostQuery, + FirestoreCollectionReference { + factory PostCollectionReference(DocumentReference parent) = + _$PostCollectionReference; + + static Post fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return Post.fromJson(snapshot.data()!); + } + + static Map toFirestore(Post value, SetOptions? options) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + /// A reference to the containing [UserProfileDocumentReference] if this is a subcollection. + UserProfileDocumentReference get parent; + + @override + PostDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Post value); +} + +class _$PostCollectionReference extends _$PostQuery + implements PostCollectionReference { + factory _$PostCollectionReference(DocumentReference parent) { + return _$PostCollectionReference._( + UserProfileDocumentReference(parent), + parent + .collection('posts') + .withConverter( + fromFirestore: PostCollectionReference.fromFirestore, + toFirestore: PostCollectionReference.toFirestore, + ), + ); + } + + _$PostCollectionReference._(this.parent, CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + @override + final UserProfileDocumentReference parent; + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + PostDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return PostDocumentReference(reference.doc(id)); + } + + @override + Future add(Post value) { + return reference.add(value).then((ref) => PostDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$PostCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class PostDocumentReference + extends FirestoreDocumentReference { + factory PostDocumentReference(DocumentReference reference) = + _$PostDocumentReference; + + DocumentReference get reference; + + /// A reference to the [PostCollectionReference] containing this document. + PostCollectionReference get parent { + return _$PostCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: UserProfileCollectionReference.fromFirestore, + toFirestore: UserProfileCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Post model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue titleFieldValue, + FieldValue contentFieldValue, + FieldValue authorIdFieldValue, + FieldValue createdAtFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Post model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue titleFieldValue, + FieldValue contentFieldValue, + FieldValue authorIdFieldValue, + FieldValue createdAtFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Post model, { + SetOptions? options, + FieldValue idFieldValue, + FieldValue titleFieldValue, + FieldValue contentFieldValue, + FieldValue authorIdFieldValue, + FieldValue createdAtFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String id, + FieldValue idFieldValue, + String title, + FieldValue titleFieldValue, + String content, + FieldValue contentFieldValue, + String authorId, + FieldValue authorIdFieldValue, + DateTime createdAt, + FieldValue createdAtFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String id, + FieldValue idFieldValue, + String title, + FieldValue titleFieldValue, + String content, + FieldValue contentFieldValue, + String authorId, + FieldValue authorIdFieldValue, + DateTime createdAt, + FieldValue createdAtFieldValue, + }); + + /// 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, + String title, + FieldValue titleFieldValue, + String content, + FieldValue contentFieldValue, + String authorId, + FieldValue authorIdFieldValue, + DateTime createdAt, + FieldValue createdAtFieldValue, + }); +} + +class _$PostDocumentReference + extends FirestoreDocumentReference + implements PostDocumentReference { + _$PostDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [PostCollectionReference] containing this document. + PostCollectionReference get parent { + return _$PostCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: UserProfileCollectionReference.fromFirestore, + toFirestore: UserProfileCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots() { + return reference.snapshots().map(PostDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(PostDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(PostDocumentSnapshot._); + } + + Future set( + Post model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? titleFieldValue, + FieldValue? contentFieldValue, + FieldValue? authorIdFieldValue, + FieldValue? createdAtFieldValue, + }) async { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$PostFieldMap['id']!: idFieldValue, + + if (titleFieldValue != null) _$PostFieldMap['title']!: titleFieldValue, + + if (contentFieldValue != null) + _$PostFieldMap['content']!: contentFieldValue, + + if (authorIdFieldValue != null) + _$PostFieldMap['authorId']!: authorIdFieldValue, + + if (createdAtFieldValue != null) + _$PostFieldMap['createdAt']!: createdAtFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Post model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? titleFieldValue, + FieldValue? contentFieldValue, + FieldValue? authorIdFieldValue, + FieldValue? createdAtFieldValue, + }) { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$PostFieldMap['id']!: idFieldValue, + + if (titleFieldValue != null) _$PostFieldMap['title']!: titleFieldValue, + + if (contentFieldValue != null) + _$PostFieldMap['content']!: contentFieldValue, + + if (authorIdFieldValue != null) + _$PostFieldMap['authorId']!: authorIdFieldValue, + + if (createdAtFieldValue != null) + _$PostFieldMap['createdAt']!: createdAtFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Post model, { + SetOptions? options, + FieldValue? idFieldValue, + FieldValue? titleFieldValue, + FieldValue? contentFieldValue, + FieldValue? authorIdFieldValue, + FieldValue? createdAtFieldValue, + }) { + final json = { + ...model.toJson(), + if (idFieldValue != null) _$PostFieldMap['id']!: idFieldValue, + + if (titleFieldValue != null) _$PostFieldMap['title']!: titleFieldValue, + + if (contentFieldValue != null) + _$PostFieldMap['content']!: contentFieldValue, + + if (authorIdFieldValue != null) + _$PostFieldMap['authorId']!: authorIdFieldValue, + + if (createdAtFieldValue != null) + _$PostFieldMap['createdAt']!: createdAtFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? id = _sentinel, + FieldValue? idFieldValue, + Object? title = _sentinel, + FieldValue? titleFieldValue, + Object? content = _sentinel, + FieldValue? contentFieldValue, + Object? authorId = _sentinel, + FieldValue? authorIdFieldValue, + Object? createdAt = _sentinel, + FieldValue? createdAtFieldValue, + }) async { + assert( + id == _sentinel || idFieldValue == null, + "Cannot specify both id and idFieldValue", + ); + assert( + title == _sentinel || titleFieldValue == null, + "Cannot specify both title and titleFieldValue", + ); + assert( + content == _sentinel || contentFieldValue == null, + "Cannot specify both content and contentFieldValue", + ); + assert( + authorId == _sentinel || authorIdFieldValue == null, + "Cannot specify both authorId and authorIdFieldValue", + ); + assert( + createdAt == _sentinel || createdAtFieldValue == null, + "Cannot specify both createdAt and createdAtFieldValue", + ); + final json = { + if (id != _sentinel) + _$PostFieldMap['id']!: _$PostPerFieldToJson.id(id as String), + + if (idFieldValue != null) _$PostFieldMap['id']!: idFieldValue, + + if (title != _sentinel) + _$PostFieldMap['title']!: _$PostPerFieldToJson.title(title as String), + + if (titleFieldValue != null) _$PostFieldMap['title']!: titleFieldValue, + + if (content != _sentinel) + _$PostFieldMap['content']!: _$PostPerFieldToJson.content( + content as String, + ), + + if (contentFieldValue != null) + _$PostFieldMap['content']!: contentFieldValue, + + if (authorId != _sentinel) + _$PostFieldMap['authorId']!: _$PostPerFieldToJson.authorId( + authorId as String, + ), + + if (authorIdFieldValue != null) + _$PostFieldMap['authorId']!: authorIdFieldValue, + + if (createdAt != _sentinel) + _$PostFieldMap['createdAt']!: _$PostPerFieldToJson.createdAt( + createdAt as DateTime, + ), + + if (createdAtFieldValue != null) + _$PostFieldMap['createdAt']!: createdAtFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + Object? id = _sentinel, + FieldValue? idFieldValue, + Object? title = _sentinel, + FieldValue? titleFieldValue, + Object? content = _sentinel, + FieldValue? contentFieldValue, + Object? authorId = _sentinel, + FieldValue? authorIdFieldValue, + Object? createdAt = _sentinel, + FieldValue? createdAtFieldValue, + }) { + assert( + id == _sentinel || idFieldValue == null, + "Cannot specify both id and idFieldValue", + ); + assert( + title == _sentinel || titleFieldValue == null, + "Cannot specify both title and titleFieldValue", + ); + assert( + content == _sentinel || contentFieldValue == null, + "Cannot specify both content and contentFieldValue", + ); + assert( + authorId == _sentinel || authorIdFieldValue == null, + "Cannot specify both authorId and authorIdFieldValue", + ); + assert( + createdAt == _sentinel || createdAtFieldValue == null, + "Cannot specify both createdAt and createdAtFieldValue", + ); + final json = { + if (id != _sentinel) + _$PostFieldMap['id']!: _$PostPerFieldToJson.id(id as String), + + if (idFieldValue != null) _$PostFieldMap['id']!: idFieldValue, + + if (title != _sentinel) + _$PostFieldMap['title']!: _$PostPerFieldToJson.title(title as String), + + if (titleFieldValue != null) _$PostFieldMap['title']!: titleFieldValue, + + if (content != _sentinel) + _$PostFieldMap['content']!: _$PostPerFieldToJson.content( + content as String, + ), + + if (contentFieldValue != null) + _$PostFieldMap['content']!: contentFieldValue, + + if (authorId != _sentinel) + _$PostFieldMap['authorId']!: _$PostPerFieldToJson.authorId( + authorId as String, + ), + + if (authorIdFieldValue != null) + _$PostFieldMap['authorId']!: authorIdFieldValue, + + if (createdAt != _sentinel) + _$PostFieldMap['createdAt']!: _$PostPerFieldToJson.createdAt( + createdAt as DateTime, + ), + + if (createdAtFieldValue != null) + _$PostFieldMap['createdAt']!: createdAtFieldValue, + }; + + transaction.update(reference, json); + } + + void batchUpdate( + WriteBatch batch, { + Object? id = _sentinel, + FieldValue? idFieldValue, + Object? title = _sentinel, + FieldValue? titleFieldValue, + Object? content = _sentinel, + FieldValue? contentFieldValue, + Object? authorId = _sentinel, + FieldValue? authorIdFieldValue, + Object? createdAt = _sentinel, + FieldValue? createdAtFieldValue, + }) { + assert( + id == _sentinel || idFieldValue == null, + "Cannot specify both id and idFieldValue", + ); + assert( + title == _sentinel || titleFieldValue == null, + "Cannot specify both title and titleFieldValue", + ); + assert( + content == _sentinel || contentFieldValue == null, + "Cannot specify both content and contentFieldValue", + ); + assert( + authorId == _sentinel || authorIdFieldValue == null, + "Cannot specify both authorId and authorIdFieldValue", + ); + assert( + createdAt == _sentinel || createdAtFieldValue == null, + "Cannot specify both createdAt and createdAtFieldValue", + ); + final json = { + if (id != _sentinel) + _$PostFieldMap['id']!: _$PostPerFieldToJson.id(id as String), + + if (idFieldValue != null) _$PostFieldMap['id']!: idFieldValue, + + if (title != _sentinel) + _$PostFieldMap['title']!: _$PostPerFieldToJson.title(title as String), + + if (titleFieldValue != null) _$PostFieldMap['title']!: titleFieldValue, + + if (content != _sentinel) + _$PostFieldMap['content']!: _$PostPerFieldToJson.content( + content as String, + ), + + if (contentFieldValue != null) + _$PostFieldMap['content']!: contentFieldValue, + + if (authorId != _sentinel) + _$PostFieldMap['authorId']!: _$PostPerFieldToJson.authorId( + authorId as String, + ), + + if (authorIdFieldValue != null) + _$PostFieldMap['authorId']!: authorIdFieldValue, + + if (createdAt != _sentinel) + _$PostFieldMap['createdAt']!: _$PostPerFieldToJson.createdAt( + createdAt as DateTime, + ), + + if (createdAtFieldValue != null) + _$PostFieldMap['createdAt']!: createdAtFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is PostDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class PostQuery implements QueryReference { + @override + PostQuery limit(int limit); + + @override + PostQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + PostQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PostQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PostQuery whereId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PostQuery whereTitle({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PostQuery whereContent({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PostQuery whereAuthorId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + PostQuery whereCreatedAt({ + DateTime? isEqualTo, + DateTime? isNotEqualTo, + DateTime? isLessThan, + DateTime? isLessThanOrEqualTo, + DateTime? isGreaterThan, + DateTime? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + PostQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }); + + PostQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }); + + PostQuery orderById({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }); + + PostQuery orderByTitle({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }); + + PostQuery orderByContent({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }); + + PostQuery orderByAuthorId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }); + + PostQuery orderByCreatedAt({ + bool descending = false, + DateTime startAt, + DateTime startAfter, + DateTime endAt, + DateTime endBefore, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }); +} + +class _$PostQuery extends QueryReference + implements PostQuery { + _$PostQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(PostQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(PostQuerySnapshot._fromQuerySnapshot); + } + + @override + PostQuery limit(int limit) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery limitToLast(int limit) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery whereId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PostFieldMap['id']!, + isEqualTo: isEqualTo != _sentinel + ? _$PostPerFieldToJson.id(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PostPerFieldToJson.id(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PostPerFieldToJson.id(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PostPerFieldToJson.id(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$PostPerFieldToJson.id(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PostPerFieldToJson.id(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$PostPerFieldToJson.id(e)), + whereNotIn: whereNotIn?.map((e) => _$PostPerFieldToJson.id(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery whereTitle({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PostFieldMap['title']!, + isEqualTo: isEqualTo != _sentinel + ? _$PostPerFieldToJson.title(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PostPerFieldToJson.title(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PostPerFieldToJson.title(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PostPerFieldToJson.title(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$PostPerFieldToJson.title(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PostPerFieldToJson.title(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$PostPerFieldToJson.title(e)), + whereNotIn: whereNotIn?.map((e) => _$PostPerFieldToJson.title(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery whereContent({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PostFieldMap['content']!, + isEqualTo: isEqualTo != _sentinel + ? _$PostPerFieldToJson.content(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PostPerFieldToJson.content(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PostPerFieldToJson.content(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PostPerFieldToJson.content(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$PostPerFieldToJson.content(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PostPerFieldToJson.content(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$PostPerFieldToJson.content(e)), + whereNotIn: whereNotIn?.map((e) => _$PostPerFieldToJson.content(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery whereAuthorId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PostFieldMap['authorId']!, + isEqualTo: isEqualTo != _sentinel + ? _$PostPerFieldToJson.authorId(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PostPerFieldToJson.authorId(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$PostPerFieldToJson.authorId(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PostPerFieldToJson.authorId(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$PostPerFieldToJson.authorId(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PostPerFieldToJson.authorId(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$PostPerFieldToJson.authorId(e)), + whereNotIn: whereNotIn?.map((e) => _$PostPerFieldToJson.authorId(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery whereCreatedAt({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$PostQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$PostFieldMap['createdAt']!, + isEqualTo: isEqualTo != _sentinel + ? _$PostPerFieldToJson.createdAt(isEqualTo as DateTime) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$PostPerFieldToJson.createdAt(isNotEqualTo as DateTime) + : null, + isLessThan: isLessThan != null + ? _$PostPerFieldToJson.createdAt(isLessThan as DateTime) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$PostPerFieldToJson.createdAt(isLessThanOrEqualTo as DateTime) + : null, + isGreaterThan: isGreaterThan != null + ? _$PostPerFieldToJson.createdAt(isGreaterThan as DateTime) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$PostPerFieldToJson.createdAt(isGreaterThanOrEqualTo as DateTime) + : null, + whereIn: whereIn?.map((e) => _$PostPerFieldToJson.createdAt(e)), + whereNotIn: whereNotIn?.map((e) => _$PostPerFieldToJson.createdAt(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + PostQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PostQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PostQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PostQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PostQuery orderById({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PostFieldMap['id']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PostPerFieldToJson.id(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PostPerFieldToJson.id(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, _$PostPerFieldToJson.id(endAt as String)], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PostPerFieldToJson.id(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PostQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PostQuery orderByTitle({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PostFieldMap['title']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PostPerFieldToJson.title(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PostPerFieldToJson.title(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PostPerFieldToJson.title(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PostPerFieldToJson.title(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PostQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PostQuery orderByContent({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PostFieldMap['content']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PostPerFieldToJson.content(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PostPerFieldToJson.content(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PostPerFieldToJson.content(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PostPerFieldToJson.content(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PostQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PostQuery orderByAuthorId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PostFieldMap['authorId']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PostPerFieldToJson.authorId(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PostPerFieldToJson.authorId(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PostPerFieldToJson.authorId(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PostPerFieldToJson.authorId(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PostQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + PostQuery orderByCreatedAt({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + PostDocumentSnapshot? startAtDocument, + PostDocumentSnapshot? endAtDocument, + PostDocumentSnapshot? endBeforeDocument, + PostDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$PostFieldMap['createdAt']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$PostPerFieldToJson.createdAt(startAt as DateTime), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$PostPerFieldToJson.createdAt(startAfter as DateTime), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$PostPerFieldToJson.createdAt(endAt as DateTime), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$PostPerFieldToJson.createdAt(endBefore as DateTime), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$PostQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$PostQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class PostDocumentSnapshot extends FirestoreDocumentSnapshot { + PostDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + PostDocumentReference get reference { + return PostDocumentReference(snapshot.reference); + } + + @override + final Post? data; +} + +class PostQuerySnapshot + extends FirestoreQuerySnapshot { + PostQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory PostQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { + final docs = snapshot.docs.map(PostQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, PostDocumentSnapshot._); + }).toList(); + + return PostQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange _decodeDocumentChange( + DocumentChange docChange, + PostDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class PostQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements PostDocumentSnapshot { + PostQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Post data; + + @override + PostDocumentReference get reference { + return PostDocumentReference(snapshot.reference); + } +} diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.freezed.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.freezed.dart new file mode 100644 index 0000000..6eacb9d --- /dev/null +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.freezed.dart @@ -0,0 +1,283 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'riverpod_integration.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +// dart format off +T _$identity(T value) => value; + +/// @nodoc +mixin _$Person { + + String get firstName;@JsonKey(name: 'LAST_NAME') String get lastName;@JsonKey(includeFromJson: false, includeToJson: false) int? get ignored; +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PersonCopyWith get copyWith => _$PersonCopyWithImpl(this as Person, _$identity); + + /// Serializes this Person to a JSON map. + Map toJson(); + + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; +} + + +} + +/// @nodoc +abstract mixin class $PersonCopyWith<$Res> { + factory $PersonCopyWith(Person value, $Res Function(Person) _then) = _$PersonCopyWithImpl; +@useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); + + + + +} +/// @nodoc +class _$PersonCopyWithImpl<$Res> + implements $PersonCopyWith<$Res> { + _$PersonCopyWithImpl(this._self, this._then); + + final Person _self; + final $Res Function(Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_self.copyWith( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [Person]. +extension PersonPatterns on Person { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Person value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Person value) $default,){ +final _that = this; +switch (_that) { +case _Person(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Person value)? $default,){ +final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored) $default,) {final _that = this; +switch (_that) { +case _Person(): +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String firstName, @JsonKey(name: 'LAST_NAME') String lastName, @JsonKey(includeFromJson: false, includeToJson: false) int? ignored)? $default,) {final _that = this; +switch (_that) { +case _Person() when $default != null: +return $default(_that.firstName,_that.lastName,_that.ignored);case _: + return null; + +} +} + +} + +/// @nodoc + +@JsonSerializable(fieldRename: FieldRename.snake) +class _Person implements Person { + _Person({required this.firstName, @JsonKey(name: 'LAST_NAME') required this.lastName, @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); + factory _Person.fromJson(Map json) => _$PersonFromJson(json); + +@override final String firstName; +@override@JsonKey(name: 'LAST_NAME') final String lastName; +@override@JsonKey(includeFromJson: false, includeToJson: false) final int? ignored; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$PersonCopyWith<_Person> get copyWith => __$PersonCopyWithImpl<_Person>(this, _$identity); + +@override +Map toJson() { + return _$PersonToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Person&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.ignored, ignored) || other.ignored == ignored)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,firstName,lastName,ignored); + +@override +String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; +} + + +} + +/// @nodoc +abstract mixin class _$PersonCopyWith<$Res> implements $PersonCopyWith<$Res> { + factory _$PersonCopyWith(_Person value, $Res Function(_Person) _then) = __$PersonCopyWithImpl; +@override @useResult +$Res call({ + String firstName,@JsonKey(name: 'LAST_NAME') String lastName,@JsonKey(includeFromJson: false, includeToJson: false) int? ignored +}); + + + + +} +/// @nodoc +class __$PersonCopyWithImpl<$Res> + implements _$PersonCopyWith<$Res> { + __$PersonCopyWithImpl(this._self, this._then); + + final _Person _self; + final $Res Function(_Person) _then; + +/// Create a copy of Person +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? firstName = null,Object? lastName = null,Object? ignored = freezed,}) { + return _then(_Person( +firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,ignored: freezed == ignored ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable +as int?, + )); +} + + +} + +// dart format on diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.g.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.g.dart new file mode 100644 index 0000000..cef3961 --- /dev/null +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.g.dart @@ -0,0 +1,538 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'riverpod_integration.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +UserProfile _$UserProfileFromJson(Map json) => UserProfile( + id: json['id'] as String, + name: json['name'] as String, + email: json['email'] as String, + age: (json['age'] as num?)?.toInt(), +); + +const _$UserProfileFieldMap = { + 'id': 'id', + 'name': 'name', + 'email': 'email', + 'age': 'age', +}; + +// ignore: unused_element +abstract class _$UserProfilePerFieldToJson { + // ignore: unused_element + static Object? id(String instance) => instance; + // ignore: unused_element + static Object? name(String instance) => instance; + // ignore: unused_element + static Object? email(String instance) => instance; + // ignore: unused_element + static Object? age(int? instance) => instance; +} + +Map _$UserProfileToJson(UserProfile instance) => + { + 'id': instance.id, + 'name': instance.name, + 'email': instance.email, + 'age': instance.age, + }; + +Post _$PostFromJson(Map json) => Post( + id: json['id'] as String, + title: json['title'] as String, + content: json['content'] as String, + authorId: json['authorId'] as String, + createdAt: const FirestoreDateTimeConverter().fromJson( + json['createdAt'] as Timestamp, + ), +); + +const _$PostFieldMap = { + 'id': 'id', + 'title': 'title', + 'content': 'content', + 'authorId': 'authorId', + 'createdAt': 'createdAt', +}; + +// ignore: unused_element +abstract class _$PostPerFieldToJson { + // ignore: unused_element + static Object? id(String instance) => instance; + // ignore: unused_element + static Object? title(String instance) => instance; + // ignore: unused_element + static Object? content(String instance) => instance; + // ignore: unused_element + static Object? authorId(String instance) => instance; + // ignore: unused_element + static Object? createdAt(DateTime instance) => + const FirestoreDateTimeConverter().toJson(instance); +} + +Map _$PostToJson(Post instance) => { + 'id': instance.id, + 'title': instance.title, + 'content': instance.content, + 'authorId': instance.authorId, + 'createdAt': const FirestoreDateTimeConverter().toJson(instance.createdAt), +}; + +AppSettings _$AppSettingsFromJson(Map json) => AppSettings( + theme: json['theme'] as String, + notifications: json['notifications'] as bool, +); + +const _$AppSettingsFieldMap = { + 'theme': 'theme', + 'notifications': 'notifications', +}; + +// ignore: unused_element +abstract class _$AppSettingsPerFieldToJson { + // ignore: unused_element + static Object? theme(String instance) => instance; + // ignore: unused_element + static Object? notifications(bool instance) => instance; +} + +Map _$AppSettingsToJson(AppSettings instance) => + { + 'theme': instance.theme, + 'notifications': instance.notifications, + }; + +_Person _$PersonFromJson(Map json) => _Person( + firstName: json['first_name'] as String, + lastName: json['LAST_NAME'] as String, +); + +const _$PersonFieldMap = { + 'firstName': 'first_name', + 'lastName': 'LAST_NAME', +}; + +// ignore: unused_element +abstract class _$PersonPerFieldToJson { + // ignore: unused_element + static Object? firstName(String instance) => instance; + // ignore: unused_element + static Object? lastName(String instance) => instance; +} + +Map _$PersonToJson(_Person instance) => { + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; + +// ************************************************************************** +// RiverpodGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, type=warning +/// Riverpod provider for user profiles collection + +@ProviderFor(userProfilesCollection) +const userProfilesCollectionProvider = UserProfilesCollectionProvider._(); + +/// Riverpod provider for user profiles collection + +final class UserProfilesCollectionProvider + extends $FunctionalProvider<_$Person, _$Person, _$Person> + with $Provider<_$Person> { + /// Riverpod provider for user profiles collection + const UserProfilesCollectionProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'userProfilesCollectionProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$userProfilesCollectionHash(); + + @$internal + @override + $ProviderElement<_$Person> $createElement($ProviderPointer pointer) => + $ProviderElement(pointer); + + @override + _$Person create(Ref ref) { + return userProfilesCollection(ref); + } + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(_$Person value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider<_$Person>(value), + ); + } +} + +String _$userProfilesCollectionHash() => + r'30dd7391a6180e68c5e632f96aa3856ca161c744'; + +/// Riverpod provider for a specific user profile + +@ProviderFor(userProfile) +const userProfileProvider = UserProfileFamily._(); + +/// Riverpod provider for a specific user profile + +final class UserProfileProvider + extends + $FunctionalProvider< + AsyncValue, + UserProfile?, + Stream + > + with $FutureModifier, $StreamProvider { + /// Riverpod provider for a specific user profile + const UserProfileProvider._({ + required UserProfileFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'userProfileProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$userProfileHash(); + + @override + String toString() { + return r'userProfileProvider' + '' + '($argument)'; + } + + @$internal + @override + $StreamProviderElement $createElement( + $ProviderPointer pointer, + ) => $StreamProviderElement(pointer); + + @override + Stream create(Ref ref) { + final argument = this.argument as String; + return userProfile(ref, argument); + } + + @override + bool operator ==(Object other) { + return other is UserProfileProvider && other.argument == argument; + } + + @override + int get hashCode { + return argument.hashCode; + } +} + +String _$userProfileHash() => r'cb26738228ef2c452d5c2b231f6898251f9af62b'; + +/// Riverpod provider for a specific user profile + +final class UserProfileFamily extends $Family + with $FunctionalFamilyOverride, String> { + const UserProfileFamily._() + : super( + retry: null, + name: r'userProfileProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + /// Riverpod provider for a specific user profile + + UserProfileProvider call(String userId) => + UserProfileProvider._(argument: userId, from: this); + + @override + String toString() => r'userProfileProvider'; +} + +/// Riverpod provider for all user profiles + +@ProviderFor(allUserProfiles) +const allUserProfilesProvider = AllUserProfilesProvider._(); + +/// Riverpod provider for all user profiles + +final class AllUserProfilesProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + Stream> + > + with + $FutureModifier>, + $StreamProvider> { + /// Riverpod provider for all user profiles + const AllUserProfilesProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'allUserProfilesProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$allUserProfilesHash(); + + @$internal + @override + $StreamProviderElement> $createElement( + $ProviderPointer pointer, + ) => $StreamProviderElement(pointer); + + @override + Stream> create(Ref ref) { + return allUserProfiles(ref); + } +} + +String _$allUserProfilesHash() => r'd835ea11db48e7bac7a438884a6d55ad47844ac0'; + +/// Riverpod provider for posts by author + +@ProviderFor(postsByAuthor) +const postsByAuthorProvider = PostsByAuthorFamily._(); + +/// Riverpod provider for posts by author + +final class PostsByAuthorProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + Stream> + > + with $FutureModifier>, $StreamProvider> { + /// Riverpod provider for posts by author + const PostsByAuthorProvider._({ + required PostsByAuthorFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'postsByAuthorProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$postsByAuthorHash(); + + @override + String toString() { + return r'postsByAuthorProvider' + '' + '($argument)'; + } + + @$internal + @override + $StreamProviderElement> $createElement($ProviderPointer pointer) => + $StreamProviderElement(pointer); + + @override + Stream> create(Ref ref) { + final argument = this.argument as String; + return postsByAuthor(ref, argument); + } + + @override + bool operator ==(Object other) { + return other is PostsByAuthorProvider && other.argument == argument; + } + + @override + int get hashCode { + return argument.hashCode; + } +} + +String _$postsByAuthorHash() => r'd5b51c409a22865278b51231c0ccf9a37747a71e'; + +/// Riverpod provider for posts by author + +final class PostsByAuthorFamily extends $Family + with $FunctionalFamilyOverride>, String> { + const PostsByAuthorFamily._() + : super( + retry: null, + name: r'postsByAuthorProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + /// Riverpod provider for posts by author + + PostsByAuthorProvider call(String authorId) => + PostsByAuthorProvider._(argument: authorId, from: this); + + @override + String toString() => r'postsByAuthorProvider'; +} + +/// Riverpod provider for recent posts + +@ProviderFor(recentPosts) +const recentPostsProvider = RecentPostsFamily._(); + +/// Riverpod provider for recent posts + +final class RecentPostsProvider + extends + $FunctionalProvider< + AsyncValue>, + List, + Stream> + > + with $FutureModifier>, $StreamProvider> { + /// Riverpod provider for recent posts + const RecentPostsProvider._({ + required RecentPostsFamily super.from, + required String super.argument, + }) : super( + retry: null, + name: r'recentPostsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$recentPostsHash(); + + @override + String toString() { + return r'recentPostsProvider' + '' + '($argument)'; + } + + @$internal + @override + $StreamProviderElement> $createElement($ProviderPointer pointer) => + $StreamProviderElement(pointer); + + @override + Stream> create(Ref ref) { + final argument = this.argument as String; + return recentPosts(ref, argument); + } + + @override + bool operator ==(Object other) { + return other is RecentPostsProvider && other.argument == argument; + } + + @override + int get hashCode { + return argument.hashCode; + } +} + +String _$recentPostsHash() => r'84d6adf0820593b072f217342208cf7310809d81'; + +/// Riverpod provider for recent posts + +final class RecentPostsFamily extends $Family + with $FunctionalFamilyOverride>, String> { + const RecentPostsFamily._() + : super( + retry: null, + name: r'recentPostsProvider', + dependencies: null, + $allTransitiveDependencies: null, + isAutoDispose: true, + ); + + /// Riverpod provider for recent posts + + RecentPostsProvider call(String authorId) => + RecentPostsProvider._(argument: authorId, from: this); + + @override + String toString() => r'recentPostsProvider'; +} + +/// Riverpod provider for app settings + +@ProviderFor(AppSettingsNotifier) +const appSettingsProvider = AppSettingsNotifierProvider._(); + +/// Riverpod provider for app settings +final class AppSettingsNotifierProvider + extends $NotifierProvider { + /// Riverpod provider for app settings + const AppSettingsNotifierProvider._() + : super( + from: null, + argument: null, + retry: null, + name: r'appSettingsProvider', + isAutoDispose: true, + dependencies: null, + $allTransitiveDependencies: null, + ); + + @override + String debugGetCreateSourceHash() => _$appSettingsNotifierHash(); + + @$internal + @override + AppSettingsNotifier create() => AppSettingsNotifier(); + + /// {@macro riverpod.override_with_value} + Override overrideWithValue(AppSettings value) { + return $ProviderOverride( + origin: this, + providerOverride: $SyncValueProvider(value), + ); + } +} + +String _$appSettingsNotifierHash() => + r'4b4f2b1eff126b10d15bd9e1c32e2432c3a6afaa'; + +/// Riverpod provider for app settings + +abstract class _$AppSettingsNotifier extends $Notifier { + AppSettings build(); + @$mustCallSuper + @override + void runBuild() { + final created = build(); + final ref = this.ref as $Ref; + final element = + ref.element + as $ClassProviderElement< + AnyNotifier, + AppSettings, + Object?, + Object? + >; + element.handleValue(ref, created); + } +} diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart index 038ef41..5e69be4 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.dart @@ -6,6 +6,7 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:json_annotation/json_annotation.dart'; +part 'simple.firebase.dart'; part 'simple.g.dart'; final ignoredGetterRef = IgnoredGetterCollectionReference(); @@ -35,11 +36,7 @@ class Model { final String value; } -enum TestEnum { - one, - two, - three; -} +enum TestEnum { one, two, three } @JsonSerializable() class Nested { @@ -85,8 +82,7 @@ final nestedRef = NestedCollectionReference(); class EmptyModel { EmptyModel(); - factory EmptyModel.fromJson(Map json) => - _$EmptyModelFromJson(json); + factory EmptyModel.fromJson(Map json) => _$EmptyModelFromJson(json); Map toJson() => _$EmptyModelToJson(this); } @@ -136,8 +132,7 @@ final optionalJsonRef = OptionalJsonCollectionReference(); class MixedJson { MixedJson(this.value); - factory MixedJson.fromJson(Map json) => - MixedJson(json['foo']! as int); + factory MixedJson.fromJson(Map json) => MixedJson(json['foo']! as int); final int value; @@ -163,8 +158,7 @@ class Sub { class CustomSubName { CustomSubName(this.value); - factory CustomSubName.fromJson(Map json) => - _$CustomSubNameFromJson(json); + factory CustomSubName.fromJson(Map json) => _$CustomSubNameFromJson(json); final num value; @@ -175,8 +169,7 @@ class CustomSubName { class AsCamelCase { AsCamelCase(this.value); - factory AsCamelCase.fromJson(Map json) => - _$AsCamelCaseFromJson(json); + factory AsCamelCase.fromJson(Map json) => _$AsCamelCaseFromJson(json); final num value; @@ -199,18 +192,14 @@ class CustomClassPrefix { @Collection('root/*/sub') @Collection('root/*/as-camel-case') @Collection('root/*/custom-sub-name', name: 'thisIsACustomName') -@Collection( - 'root/*/custom-class-prefix', - prefix: 'ThisIsACustomPrefix', -) +@Collection('root/*/custom-class-prefix', prefix: 'ThisIsACustomPrefix') final rootRef = RootCollectionReference(); @JsonSerializable() class ExplicitPath { ExplicitPath(this.value); - factory ExplicitPath.fromJson(Map json) => - _$ExplicitPathFromJson(json); + factory ExplicitPath.fromJson(Map json) => _$ExplicitPathFromJson(json); final num value; @@ -221,8 +210,7 @@ class ExplicitPath { class ExplicitSubPath { ExplicitSubPath(this.value); - factory ExplicitSubPath.fromJson(Map json) => - _$ExplicitSubPathFromJson(json); + factory ExplicitSubPath.fromJson(Map json) => _$ExplicitSubPathFromJson(json); final num value; @@ -244,8 +232,7 @@ abstract class BaseClass { class SubClass extends BaseClass { SubClass(super.instanceGetter); - factory SubClass.fromJson(Map json) => - _$SubClassFromJson(json); + factory SubClass.fromJson(Map json) => _$SubClassFromJson(json); Map toJson() => _$SubClassToJson(this); } diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.firebase.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.firebase.dart new file mode 100644 index 0000000..a22fd7b --- /dev/null +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.firebase.dart @@ -0,0 +1,16148 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// dart format width=80 + +part of 'simple.dart'; + +// ************************************************************************** +// CollectionGenerator +// ************************************************************************** + +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore +// ignore_for_file: type=lint +// ignore_for_file: invalid_use_of_internal_member + +class _Sentinel { + const _Sentinel(); +} + +const _sentinel = _Sentinel(); + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class IgnoredGetterCollectionReference + implements + IgnoredGetterQuery, + FirestoreCollectionReference< + IgnoredGetter, + IgnoredGetterQuerySnapshot + > { + factory IgnoredGetterCollectionReference([FirebaseFirestore? firestore]) = + _$IgnoredGetterCollectionReference; + + static IgnoredGetter fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$IgnoredGetterFromJson(snapshot.data()!); + } + + static Map toFirestore( + IgnoredGetter value, + SetOptions? options, + ) { + return _$IgnoredGetterToJson(value); + } + + @override + CollectionReference get reference; + + @override + IgnoredGetterDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(IgnoredGetter value); +} + +class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery + implements IgnoredGetterCollectionReference { + factory _$IgnoredGetterCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$IgnoredGetterCollectionReference._( + firestore + .collection('firestore-example-app/test/getter') + .withConverter( + fromFirestore: IgnoredGetterCollectionReference.fromFirestore, + toFirestore: IgnoredGetterCollectionReference.toFirestore, + ), + ); + } + + _$IgnoredGetterCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + IgnoredGetterDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return IgnoredGetterDocumentReference(reference.doc(id)); + } + + @override + Future add(IgnoredGetter value) { + return reference + .add(value) + .then((ref) => IgnoredGetterDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$IgnoredGetterCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class IgnoredGetterDocumentReference + extends + FirestoreDocumentReference< + IgnoredGetter, + IgnoredGetterDocumentSnapshot + > { + factory IgnoredGetterDocumentReference( + DocumentReference reference, + ) = _$IgnoredGetterDocumentReference; + + DocumentReference get reference; + + /// A reference to the [IgnoredGetterCollectionReference] containing this document. + IgnoredGetterCollectionReference get parent { + return _$IgnoredGetterCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + IgnoredGetter model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + IgnoredGetter model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + IgnoredGetter model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({int value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + implements IgnoredGetterDocumentReference { + _$IgnoredGetterDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [IgnoredGetterCollectionReference] containing this document. + IgnoredGetterCollectionReference get parent { + return _$IgnoredGetterCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(IgnoredGetterDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(IgnoredGetterDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(IgnoredGetterDocumentSnapshot._); + } + + Future set( + IgnoredGetter model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ..._$IgnoredGetterToJson(model), + if (valueFieldValue != null) + _$IgnoredGetterFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + IgnoredGetter model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ..._$IgnoredGetterToJson(model), + if (valueFieldValue != null) + _$IgnoredGetterFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + IgnoredGetter model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ..._$IgnoredGetterToJson(model), + if (valueFieldValue != null) + _$IgnoredGetterFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class IgnoredGetterQuery + implements QueryReference { + @override + IgnoredGetterQuery limit(int limit); + + @override + IgnoredGetterQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + IgnoredGetterQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + IgnoredGetterQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + IgnoredGetterQuery whereValue({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + IgnoredGetterQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }); + + IgnoredGetterQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }); + + IgnoredGetterQuery orderByValue({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }); +} + +class _$IgnoredGetterQuery + extends QueryReference + implements IgnoredGetterQuery { + _$IgnoredGetterQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + IgnoredGetterQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(IgnoredGetterQuerySnapshot._fromQuerySnapshot); + } + + @override + IgnoredGetterQuery limit(int limit) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + IgnoredGetterQuery limitToLast(int limit) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + IgnoredGetterQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + IgnoredGetterQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + IgnoredGetterQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$IgnoredGetterFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$IgnoredGetterPerFieldToJson.value(isEqualTo as int) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$IgnoredGetterPerFieldToJson.value(isNotEqualTo as int) + : null, + isLessThan: isLessThan != null + ? _$IgnoredGetterPerFieldToJson.value(isLessThan as int) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$IgnoredGetterPerFieldToJson.value(isLessThanOrEqualTo as int) + : null, + isGreaterThan: isGreaterThan != null + ? _$IgnoredGetterPerFieldToJson.value(isGreaterThan as int) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$IgnoredGetterPerFieldToJson.value(isGreaterThanOrEqualTo as int) + : null, + whereIn: whereIn?.map((e) => _$IgnoredGetterPerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map( + (e) => _$IgnoredGetterPerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + IgnoredGetterQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + IgnoredGetterQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + IgnoredGetterQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + IgnoredGetterDocumentSnapshot? startAtDocument, + IgnoredGetterDocumentSnapshot? endAtDocument, + IgnoredGetterDocumentSnapshot? endBeforeDocument, + IgnoredGetterDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$IgnoredGetterFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$IgnoredGetterPerFieldToJson.value(startAt as int), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$IgnoredGetterPerFieldToJson.value(startAfter as int), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$IgnoredGetterPerFieldToJson.value(endAt as int), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$IgnoredGetterPerFieldToJson.value(endBefore as int), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$IgnoredGetterQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$IgnoredGetterQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class IgnoredGetterDocumentSnapshot + extends FirestoreDocumentSnapshot { + IgnoredGetterDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + IgnoredGetterDocumentReference get reference { + return IgnoredGetterDocumentReference(snapshot.reference); + } + + @override + final IgnoredGetter? data; +} + +class IgnoredGetterQuerySnapshot + extends + FirestoreQuerySnapshot< + IgnoredGetter, + IgnoredGetterQueryDocumentSnapshot + > { + IgnoredGetterQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory IgnoredGetterQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(IgnoredGetterQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, IgnoredGetterDocumentSnapshot._); + }).toList(); + + return IgnoredGetterQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + IgnoredGetterDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class IgnoredGetterQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements IgnoredGetterDocumentSnapshot { + IgnoredGetterQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final IgnoredGetter data; + + @override + IgnoredGetterDocumentReference get reference { + return IgnoredGetterDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class ModelCollectionReference + implements + ModelQuery, + FirestoreCollectionReference { + factory ModelCollectionReference([FirebaseFirestore? firestore]) = + _$ModelCollectionReference; + + static Model fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$ModelFromJson(snapshot.data()!); + } + + static Map toFirestore(Model value, SetOptions? options) { + return _$ModelToJson(value); + } + + @override + CollectionReference get reference; + + @override + ModelDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Model value); +} + +class _$ModelCollectionReference extends _$ModelQuery + implements ModelCollectionReference { + factory _$ModelCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$ModelCollectionReference._( + firestore + .collection('root') + .withConverter( + fromFirestore: ModelCollectionReference.fromFirestore, + toFirestore: ModelCollectionReference.toFirestore, + ), + ); + } + + _$ModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + ModelDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return ModelDocumentReference(reference.doc(id)); + } + + @override + Future add(Model value) { + return reference.add(value).then((ref) => ModelDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$ModelCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class ModelDocumentReference + extends FirestoreDocumentReference { + factory ModelDocumentReference(DocumentReference reference) = + _$ModelDocumentReference; + + DocumentReference get reference; + + /// A reference to the [ModelCollectionReference] containing this document. + ModelCollectionReference get parent { + return _$ModelCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Model model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Model model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Model model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({String value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + extends FirestoreDocumentReference + implements ModelDocumentReference { + _$ModelDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [ModelCollectionReference] containing this document. + ModelCollectionReference get parent { + return _$ModelCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(ModelDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(ModelDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(ModelDocumentSnapshot._); + } + + Future set( + Model model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ..._$ModelToJson(model), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Model model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ..._$ModelToJson(model), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Model model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ..._$ModelToJson(model), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class ModelQuery implements QueryReference { + @override + ModelQuery limit(int limit); + + @override + ModelQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + ModelQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ModelQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ModelQuery whereValue({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + ModelQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + ModelDocumentSnapshot? startAtDocument, + ModelDocumentSnapshot? endAtDocument, + ModelDocumentSnapshot? endBeforeDocument, + ModelDocumentSnapshot? startAfterDocument, + }); + + ModelQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + ModelDocumentSnapshot? startAtDocument, + ModelDocumentSnapshot? endAtDocument, + ModelDocumentSnapshot? endBeforeDocument, + ModelDocumentSnapshot? startAfterDocument, + }); + + ModelQuery orderByValue({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + ModelDocumentSnapshot? startAtDocument, + ModelDocumentSnapshot? endAtDocument, + ModelDocumentSnapshot? endBeforeDocument, + ModelDocumentSnapshot? startAfterDocument, + }); +} + +class _$ModelQuery extends QueryReference + implements ModelQuery { + _$ModelQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(ModelQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(ModelQuerySnapshot._fromQuerySnapshot); + } + + @override + ModelQuery limit(int limit) { + return _$ModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ModelQuery limitToLast(int limit) { + return _$ModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ModelQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ModelQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ModelQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$ModelFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$ModelPerFieldToJson.value(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$ModelPerFieldToJson.value(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$ModelPerFieldToJson.value(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$ModelPerFieldToJson.value(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$ModelPerFieldToJson.value(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$ModelPerFieldToJson.value(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$ModelPerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map((e) => _$ModelPerFieldToJson.value(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ModelQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ModelDocumentSnapshot? startAtDocument, + ModelDocumentSnapshot? endAtDocument, + ModelDocumentSnapshot? endBeforeDocument, + ModelDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ModelQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ModelQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ModelDocumentSnapshot? startAtDocument, + ModelDocumentSnapshot? endAtDocument, + ModelDocumentSnapshot? endBeforeDocument, + ModelDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ModelQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ModelQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ModelDocumentSnapshot? startAtDocument, + ModelDocumentSnapshot? endAtDocument, + ModelDocumentSnapshot? endBeforeDocument, + ModelDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$ModelFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$ModelPerFieldToJson.value(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$ModelPerFieldToJson.value(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$ModelPerFieldToJson.value(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$ModelPerFieldToJson.value(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ModelQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$ModelQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class ModelDocumentSnapshot extends FirestoreDocumentSnapshot { + ModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ModelDocumentReference get reference { + return ModelDocumentReference(snapshot.reference); + } + + @override + final Model? data; +} + +class ModelQuerySnapshot + extends FirestoreQuerySnapshot { + ModelQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory ModelQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { + final docs = snapshot.docs.map(ModelQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, ModelDocumentSnapshot._); + }).toList(); + + return ModelQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class ModelQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements ModelDocumentSnapshot { + ModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Model data; + + @override + ModelDocumentReference get reference { + return ModelDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class NestedCollectionReference + implements + NestedQuery, + FirestoreCollectionReference { + factory NestedCollectionReference([FirebaseFirestore? firestore]) = + _$NestedCollectionReference; + + static Nested fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return Nested.fromJson(snapshot.data()!); + } + + static Map toFirestore(Nested value, SetOptions? options) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + NestedDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Nested value); +} + +class _$NestedCollectionReference extends _$NestedQuery + implements NestedCollectionReference { + factory _$NestedCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$NestedCollectionReference._( + firestore + .collection('nested') + .withConverter( + fromFirestore: NestedCollectionReference.fromFirestore, + toFirestore: NestedCollectionReference.toFirestore, + ), + ); + } + + _$NestedCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + NestedDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return NestedDocumentReference(reference.doc(id)); + } + + @override + Future add(Nested value) { + return reference.add(value).then((ref) => NestedDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$NestedCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class NestedDocumentReference + extends FirestoreDocumentReference { + factory NestedDocumentReference(DocumentReference reference) = + _$NestedDocumentReference; + + DocumentReference get reference; + + /// A reference to the [NestedCollectionReference] containing this document. + NestedCollectionReference get parent { + return _$NestedCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Nested model, { + SetOptions? options, + FieldValue valueFieldValue, + FieldValue simpleFieldValue, + FieldValue valueListFieldValue, + FieldValue boolListFieldValue, + FieldValue stringListFieldValue, + FieldValue numListFieldValue, + FieldValue objectListFieldValue, + FieldValue dynamicListFieldValue, + FieldValue boolSetFieldValue, + FieldValue enumValueFieldValue, + FieldValue nullableEnumValueFieldValue, + FieldValue enumListFieldValue, + FieldValue nullableEnumListFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Nested model, { + SetOptions? options, + FieldValue valueFieldValue, + FieldValue simpleFieldValue, + FieldValue valueListFieldValue, + FieldValue boolListFieldValue, + FieldValue stringListFieldValue, + FieldValue numListFieldValue, + FieldValue objectListFieldValue, + FieldValue dynamicListFieldValue, + FieldValue boolSetFieldValue, + FieldValue enumValueFieldValue, + FieldValue nullableEnumValueFieldValue, + FieldValue enumListFieldValue, + FieldValue nullableEnumListFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Nested model, { + SetOptions? options, + FieldValue valueFieldValue, + FieldValue simpleFieldValue, + FieldValue valueListFieldValue, + FieldValue boolListFieldValue, + FieldValue stringListFieldValue, + FieldValue numListFieldValue, + FieldValue objectListFieldValue, + FieldValue dynamicListFieldValue, + FieldValue boolSetFieldValue, + FieldValue enumValueFieldValue, + FieldValue nullableEnumValueFieldValue, + FieldValue enumListFieldValue, + FieldValue nullableEnumListFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + 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, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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, + }); + + /// 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 + extends FirestoreDocumentReference + implements NestedDocumentReference { + _$NestedDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [NestedCollectionReference] containing this document. + NestedCollectionReference get parent { + return _$NestedCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(NestedDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(NestedDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(NestedDocumentSnapshot._); + } + + Future set( + Nested model, { + SetOptions? options, + FieldValue? valueFieldValue, + FieldValue? simpleFieldValue, + FieldValue? valueListFieldValue, + FieldValue? boolListFieldValue, + FieldValue? stringListFieldValue, + FieldValue? numListFieldValue, + FieldValue? objectListFieldValue, + FieldValue? dynamicListFieldValue, + FieldValue? boolSetFieldValue, + FieldValue? enumValueFieldValue, + FieldValue? nullableEnumValueFieldValue, + FieldValue? enumListFieldValue, + FieldValue? nullableEnumListFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + + if (simpleFieldValue != null) + _$NestedFieldMap['simple']!: simpleFieldValue, + + if (valueListFieldValue != null) + _$NestedFieldMap['valueList']!: valueListFieldValue, + + if (boolListFieldValue != null) + _$NestedFieldMap['boolList']!: boolListFieldValue, + + if (stringListFieldValue != null) + _$NestedFieldMap['stringList']!: stringListFieldValue, + + if (numListFieldValue != null) + _$NestedFieldMap['numList']!: numListFieldValue, + + if (objectListFieldValue != null) + _$NestedFieldMap['objectList']!: objectListFieldValue, + + if (dynamicListFieldValue != null) + _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + + if (boolSetFieldValue != null) + _$NestedFieldMap['boolSet']!: boolSetFieldValue, + + if (enumValueFieldValue != null) + _$NestedFieldMap['enumValue']!: enumValueFieldValue, + + if (nullableEnumValueFieldValue != null) + _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + + if (enumListFieldValue != null) + _$NestedFieldMap['enumList']!: enumListFieldValue, + + if (nullableEnumListFieldValue != null) + _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Nested model, { + SetOptions? options, + FieldValue? valueFieldValue, + FieldValue? simpleFieldValue, + FieldValue? valueListFieldValue, + FieldValue? boolListFieldValue, + FieldValue? stringListFieldValue, + FieldValue? numListFieldValue, + FieldValue? objectListFieldValue, + FieldValue? dynamicListFieldValue, + FieldValue? boolSetFieldValue, + FieldValue? enumValueFieldValue, + FieldValue? nullableEnumValueFieldValue, + FieldValue? enumListFieldValue, + FieldValue? nullableEnumListFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + + if (simpleFieldValue != null) + _$NestedFieldMap['simple']!: simpleFieldValue, + + if (valueListFieldValue != null) + _$NestedFieldMap['valueList']!: valueListFieldValue, + + if (boolListFieldValue != null) + _$NestedFieldMap['boolList']!: boolListFieldValue, + + if (stringListFieldValue != null) + _$NestedFieldMap['stringList']!: stringListFieldValue, + + if (numListFieldValue != null) + _$NestedFieldMap['numList']!: numListFieldValue, + + if (objectListFieldValue != null) + _$NestedFieldMap['objectList']!: objectListFieldValue, + + if (dynamicListFieldValue != null) + _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + + if (boolSetFieldValue != null) + _$NestedFieldMap['boolSet']!: boolSetFieldValue, + + if (enumValueFieldValue != null) + _$NestedFieldMap['enumValue']!: enumValueFieldValue, + + if (nullableEnumValueFieldValue != null) + _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + + if (enumListFieldValue != null) + _$NestedFieldMap['enumList']!: enumListFieldValue, + + if (nullableEnumListFieldValue != null) + _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Nested model, { + SetOptions? options, + FieldValue? valueFieldValue, + FieldValue? simpleFieldValue, + FieldValue? valueListFieldValue, + FieldValue? boolListFieldValue, + FieldValue? stringListFieldValue, + FieldValue? numListFieldValue, + FieldValue? objectListFieldValue, + FieldValue? dynamicListFieldValue, + FieldValue? boolSetFieldValue, + FieldValue? enumValueFieldValue, + FieldValue? nullableEnumValueFieldValue, + FieldValue? enumListFieldValue, + FieldValue? nullableEnumListFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + + if (simpleFieldValue != null) + _$NestedFieldMap['simple']!: simpleFieldValue, + + if (valueListFieldValue != null) + _$NestedFieldMap['valueList']!: valueListFieldValue, + + if (boolListFieldValue != null) + _$NestedFieldMap['boolList']!: boolListFieldValue, + + if (stringListFieldValue != null) + _$NestedFieldMap['stringList']!: stringListFieldValue, + + if (numListFieldValue != null) + _$NestedFieldMap['numList']!: numListFieldValue, + + if (objectListFieldValue != null) + _$NestedFieldMap['objectList']!: objectListFieldValue, + + if (dynamicListFieldValue != null) + _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + + if (boolSetFieldValue != null) + _$NestedFieldMap['boolSet']!: boolSetFieldValue, + + if (enumValueFieldValue != null) + _$NestedFieldMap['enumValue']!: enumValueFieldValue, + + if (nullableEnumValueFieldValue != null) + _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, + + if (enumListFieldValue != null) + _$NestedFieldMap['enumList']!: enumListFieldValue, + + if (nullableEnumListFieldValue != null) + _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + 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, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class NestedQuery + implements QueryReference { + @override + NestedQuery limit(int limit); + + @override + NestedQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + NestedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + NestedQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + NestedQuery whereValue({ + Nested? isEqualTo, + Nested? isNotEqualTo, + Nested? isLessThan, + Nested? isLessThanOrEqualTo, + Nested? isGreaterThan, + Nested? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + NestedQuery whereSimple({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + NestedQuery whereValueList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + Nested? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + NestedQuery whereBoolList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + bool? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + NestedQuery whereStringList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + String? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + NestedQuery whereNumList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + num? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + NestedQuery whereObjectList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + NestedQuery whereDynamicList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + dynamic arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + NestedQuery whereBoolSet({ + Set? isEqualTo, + Set? isNotEqualTo, + Set? isLessThan, + Set? isLessThanOrEqualTo, + Set? isGreaterThan, + Set? isGreaterThanOrEqualTo, + bool? arrayContains, + Set? arrayContainsAny, + bool? isNull, + }); + + NestedQuery whereEnumValue({ + TestEnum? isEqualTo, + TestEnum? isNotEqualTo, + TestEnum? isLessThan, + TestEnum? isLessThanOrEqualTo, + TestEnum? isGreaterThan, + TestEnum? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + NestedQuery whereNullableEnumValue({ + TestEnum? isEqualTo, + TestEnum? isNotEqualTo, + TestEnum? isLessThan, + TestEnum? isLessThanOrEqualTo, + TestEnum? isGreaterThan, + TestEnum? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + NestedQuery whereEnumList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + TestEnum? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + NestedQuery whereNullableEnumList({ + List? isEqualTo, + List? isNotEqualTo, + List? isLessThan, + List? isLessThanOrEqualTo, + List? isGreaterThan, + List? isGreaterThanOrEqualTo, + TestEnum? arrayContains, + List? arrayContainsAny, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + NestedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByValue({ + bool descending = false, + Nested? startAt, + Nested? startAfter, + Nested? endAt, + Nested? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderBySimple({ + bool descending = false, + int? startAt, + int? startAfter, + int? endAt, + int? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByValueList({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByBoolList({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByStringList({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByNumList({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByObjectList({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByDynamicList({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByBoolSet({ + bool descending = false, + Set? startAt, + Set? startAfter, + Set? endAt, + Set? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByEnumValue({ + bool descending = false, + TestEnum startAt, + TestEnum startAfter, + TestEnum endAt, + TestEnum endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByNullableEnumValue({ + bool descending = false, + TestEnum? startAt, + TestEnum? startAfter, + TestEnum? endAt, + TestEnum? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByEnumList({ + bool descending = false, + List startAt, + List startAfter, + List endAt, + List endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); + + NestedQuery orderByNullableEnumList({ + bool descending = false, + List? startAt, + List? startAfter, + List? endAt, + List? endBefore, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }); +} + +class _$NestedQuery extends QueryReference + implements NestedQuery { + _$NestedQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(NestedQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(NestedQuerySnapshot._fromQuerySnapshot); + } + + @override + NestedQuery limit(int limit) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery limitToLast(int limit) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.value(isEqualTo as Nested?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.value(isNotEqualTo as Nested?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.value(isLessThan as Nested?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.value(isLessThanOrEqualTo as Nested?) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.value(isGreaterThan as Nested?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.value(isGreaterThanOrEqualTo as Nested?) + : null, + whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.value(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereSimple({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['simple']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.simple(isEqualTo as int?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.simple(isNotEqualTo as int?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.simple(isLessThan as int?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.simple(isLessThanOrEqualTo as int?) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.simple(isGreaterThan as int?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.simple(isGreaterThanOrEqualTo as int?) + : null, + whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.simple(e)), + whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.simple(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereValueList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['valueList']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.valueList(isEqualTo as List?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.valueList(isNotEqualTo as List?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.valueList(isLessThan as List?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.valueList( + isLessThanOrEqualTo as List?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.valueList(isGreaterThan as List?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.valueList( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.valueList([arrayContains as Nested]) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.valueList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereBoolList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['boolList']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.boolList(isEqualTo as List?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.boolList(isNotEqualTo as List?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.boolList(isLessThan as List?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.boolList( + isLessThanOrEqualTo as List?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.boolList(isGreaterThan as List?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.boolList( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.boolList([arrayContains as bool]) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.boolList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereStringList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['stringList']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.stringList(isEqualTo as List?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.stringList(isNotEqualTo as List?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.stringList(isLessThan as List?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.stringList( + isLessThanOrEqualTo as List?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.stringList(isGreaterThan as List?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.stringList( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.stringList([arrayContains as String]) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.stringList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereNumList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['numList']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.numList(isEqualTo as List?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.numList(isNotEqualTo as List?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.numList(isLessThan as List?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.numList(isLessThanOrEqualTo as List?) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.numList(isGreaterThan as List?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.numList( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.numList([arrayContains as num]) as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.numList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereObjectList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['objectList']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.objectList(isEqualTo as List?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.objectList(isNotEqualTo as List?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.objectList(isLessThan as List?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.objectList( + isLessThanOrEqualTo as List?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.objectList(isGreaterThan as List?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.objectList( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.objectList([arrayContains]) as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.objectList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereDynamicList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['dynamicList']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.dynamicList(isEqualTo as List?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.dynamicList(isNotEqualTo as List?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.dynamicList(isLessThan as List?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.dynamicList( + isLessThanOrEqualTo as List?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.dynamicList( + isGreaterThan as List?, + ) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.dynamicList( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.dynamicList([arrayContains as dynamic]) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.dynamicList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereBoolSet({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + Set? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['boolSet']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.boolSet(isEqualTo as Set?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.boolSet(isNotEqualTo as Set?) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.boolSet(isLessThan as Set?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.boolSet(isLessThanOrEqualTo as Set?) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.boolSet(isGreaterThan as Set?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.boolSet( + isGreaterThanOrEqualTo as Set?, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.boolSet({arrayContains as bool}) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.boolSet(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereEnumValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['enumValue']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.enumValue(isEqualTo as TestEnum) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.enumValue(isNotEqualTo as TestEnum) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.enumValue(isLessThan as TestEnum) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.enumValue(isLessThanOrEqualTo as TestEnum) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.enumValue(isGreaterThan as TestEnum) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.enumValue( + isGreaterThanOrEqualTo as TestEnum, + ) + : null, + whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.enumValue(e)), + whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.enumValue(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereNullableEnumValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['nullableEnumValue']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.nullableEnumValue(isEqualTo as TestEnum?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.nullableEnumValue( + isNotEqualTo as TestEnum?, + ) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.nullableEnumValue(isLessThan as TestEnum?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.nullableEnumValue( + isLessThanOrEqualTo as TestEnum?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.nullableEnumValue( + isGreaterThan as TestEnum?, + ) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.nullableEnumValue( + isGreaterThanOrEqualTo as TestEnum?, + ) + : null, + whereIn: whereIn?.map( + (e) => _$NestedPerFieldToJson.nullableEnumValue(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$NestedPerFieldToJson.nullableEnumValue(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereEnumList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['enumList']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.enumList(isEqualTo as List) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.enumList(isNotEqualTo as List) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.enumList(isLessThan as List) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.enumList( + isLessThanOrEqualTo as List, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.enumList(isGreaterThan as List) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.enumList( + isGreaterThanOrEqualTo as List, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.enumList([arrayContains as TestEnum]) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.enumList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery whereNullableEnumList({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + bool? isNull, + }) { + return _$NestedQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$NestedFieldMap['nullableEnumList']!, + isEqualTo: isEqualTo != _sentinel + ? _$NestedPerFieldToJson.nullableEnumList( + isEqualTo as List?, + ) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$NestedPerFieldToJson.nullableEnumList( + isNotEqualTo as List?, + ) + : null, + isLessThan: isLessThan != null + ? _$NestedPerFieldToJson.nullableEnumList( + isLessThan as List?, + ) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$NestedPerFieldToJson.nullableEnumList( + isLessThanOrEqualTo as List?, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$NestedPerFieldToJson.nullableEnumList( + isGreaterThan as List?, + ) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$NestedPerFieldToJson.nullableEnumList( + isGreaterThanOrEqualTo as List?, + ) + : null, + arrayContains: arrayContains != null + ? (_$NestedPerFieldToJson.nullableEnumList([ + arrayContains as TestEnum, + ]) + as List?)! + .single + : null, + arrayContainsAny: arrayContainsAny != null + ? _$NestedPerFieldToJson.nullableEnumList(arrayContainsAny) + as Iterable? + : null, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + NestedQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.value(startAt as Nested?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.value(startAfter as Nested?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.value(endAt as Nested?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.value(endBefore as Nested?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderBySimple({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['simple']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.simple(startAt as int?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.simple(startAfter as int?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.simple(endAt as int?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.simple(endBefore as int?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByValueList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['valueList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.valueList(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.valueList(startAfter as List?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.valueList(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.valueList(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByBoolList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['boolList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.boolList(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.boolList(startAfter as List?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.boolList(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.boolList(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByStringList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['stringList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.stringList(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.stringList(startAfter as List?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.stringList(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.stringList(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByNumList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['numList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.numList(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.numList(startAfter as List?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.numList(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.numList(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByObjectList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['objectList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.objectList(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.objectList(startAfter as List?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.objectList(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.objectList(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByDynamicList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['dynamicList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.dynamicList(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.dynamicList(startAfter as List?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.dynamicList(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.dynamicList(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByBoolSet({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['boolSet']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.boolSet(startAt as Set?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.boolSet(startAfter as Set?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.boolSet(endAt as Set?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.boolSet(endBefore as Set?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByEnumValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['enumValue']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.enumValue(startAt as TestEnum), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.enumValue(startAfter as TestEnum), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.enumValue(endAt as TestEnum), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.enumValue(endBefore as TestEnum), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByNullableEnumValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['nullableEnumValue']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.nullableEnumValue(startAt as TestEnum?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.nullableEnumValue(startAfter as TestEnum?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.nullableEnumValue(endAt as TestEnum?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.nullableEnumValue(endBefore as TestEnum?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByEnumList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['enumList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.enumList(startAt as List), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.enumList(startAfter as List), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.enumList(endAt as List), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.enumList(endBefore as List), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + NestedQuery orderByNullableEnumList({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + NestedDocumentSnapshot? startAtDocument, + NestedDocumentSnapshot? endAtDocument, + NestedDocumentSnapshot? endBeforeDocument, + NestedDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['nullableEnumList']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.nullableEnumList(startAt as List?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.nullableEnumList( + startAfter as List?, + ), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.nullableEnumList(endAt as List?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.nullableEnumList(endBefore as List?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$NestedQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$NestedQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class NestedDocumentSnapshot extends FirestoreDocumentSnapshot { + NestedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + NestedDocumentReference get reference { + return NestedDocumentReference(snapshot.reference); + } + + @override + final Nested? data; +} + +class NestedQuerySnapshot + extends FirestoreQuerySnapshot { + NestedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory NestedQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(NestedQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, NestedDocumentSnapshot._); + }).toList(); + + return NestedQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + NestedDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class NestedQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements NestedDocumentSnapshot { + NestedQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Nested data; + + @override + NestedDocumentReference get reference { + return NestedDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class EmptyModelCollectionReference + implements + EmptyModelQuery, + FirestoreCollectionReference { + factory EmptyModelCollectionReference([FirebaseFirestore? firestore]) = + _$EmptyModelCollectionReference; + + static EmptyModel fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return EmptyModel.fromJson(snapshot.data()!); + } + + static Map toFirestore( + EmptyModel value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + EmptyModelDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(EmptyModel value); +} + +class _$EmptyModelCollectionReference extends _$EmptyModelQuery + implements EmptyModelCollectionReference { + factory _$EmptyModelCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$EmptyModelCollectionReference._( + firestore + .collection('config') + .withConverter( + fromFirestore: EmptyModelCollectionReference.fromFirestore, + toFirestore: EmptyModelCollectionReference.toFirestore, + ), + ); + } + + _$EmptyModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + EmptyModelDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return EmptyModelDocumentReference(reference.doc(id)); + } + + @override + Future add(EmptyModel value) { + return reference.add(value).then((ref) => EmptyModelDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$EmptyModelCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class EmptyModelDocumentReference + extends FirestoreDocumentReference { + factory EmptyModelDocumentReference(DocumentReference reference) = + _$EmptyModelDocumentReference; + + DocumentReference get reference; + + /// A reference to the [EmptyModelCollectionReference] containing this document. + EmptyModelCollectionReference get parent { + return _$EmptyModelCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); +} + +class _$EmptyModelDocumentReference + extends FirestoreDocumentReference + implements EmptyModelDocumentReference { + _$EmptyModelDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [EmptyModelCollectionReference] containing this document. + EmptyModelCollectionReference get parent { + return _$EmptyModelCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(EmptyModelDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(EmptyModelDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(EmptyModelDocumentSnapshot._); + } + + @override + bool operator ==(Object other) { + return other is EmptyModelDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class EmptyModelQuery + implements QueryReference { + @override + EmptyModelQuery limit(int limit); + + @override + EmptyModelQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + EmptyModelQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + EmptyModelQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + EmptyModelQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + EmptyModelDocumentSnapshot? startAtDocument, + EmptyModelDocumentSnapshot? endAtDocument, + EmptyModelDocumentSnapshot? endBeforeDocument, + EmptyModelDocumentSnapshot? startAfterDocument, + }); + + EmptyModelQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + EmptyModelDocumentSnapshot? startAtDocument, + EmptyModelDocumentSnapshot? endAtDocument, + EmptyModelDocumentSnapshot? endBeforeDocument, + EmptyModelDocumentSnapshot? startAfterDocument, + }); +} + +class _$EmptyModelQuery + extends QueryReference + implements EmptyModelQuery { + _$EmptyModelQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + EmptyModelQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(EmptyModelQuerySnapshot._fromQuerySnapshot); + } + + @override + EmptyModelQuery limit(int limit) { + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + EmptyModelQuery limitToLast(int limit) { + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + EmptyModelQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EmptyModelQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + EmptyModelQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EmptyModelDocumentSnapshot? startAtDocument, + EmptyModelDocumentSnapshot? endAtDocument, + EmptyModelDocumentSnapshot? endBeforeDocument, + EmptyModelDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + EmptyModelQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + EmptyModelDocumentSnapshot? startAtDocument, + EmptyModelDocumentSnapshot? endAtDocument, + EmptyModelDocumentSnapshot? endBeforeDocument, + EmptyModelDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$EmptyModelQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$EmptyModelQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { + EmptyModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + EmptyModelDocumentReference get reference { + return EmptyModelDocumentReference(snapshot.reference); + } + + @override + final EmptyModel? data; +} + +class EmptyModelQuerySnapshot + extends + FirestoreQuerySnapshot { + EmptyModelQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory EmptyModelQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(EmptyModelQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, EmptyModelDocumentSnapshot._); + }).toList(); + + return EmptyModelQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class EmptyModelQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements EmptyModelDocumentSnapshot { + EmptyModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final EmptyModel data; + + @override + EmptyModelDocumentReference get reference { + return EmptyModelDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class OptionalJsonCollectionReference + implements + OptionalJsonQuery, + FirestoreCollectionReference { + factory OptionalJsonCollectionReference([FirebaseFirestore? firestore]) = + _$OptionalJsonCollectionReference; + + static OptionalJson fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$OptionalJsonFromJson(snapshot.data()!); + } + + static Map toFirestore( + OptionalJson value, + SetOptions? options, + ) { + return _$OptionalJsonToJson(value); + } + + @override + CollectionReference get reference; + + @override + OptionalJsonDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(OptionalJson value); +} + +class _$OptionalJsonCollectionReference extends _$OptionalJsonQuery + implements OptionalJsonCollectionReference { + factory _$OptionalJsonCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$OptionalJsonCollectionReference._( + firestore + .collection('root') + .withConverter( + fromFirestore: OptionalJsonCollectionReference.fromFirestore, + toFirestore: OptionalJsonCollectionReference.toFirestore, + ), + ); + } + + _$OptionalJsonCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + OptionalJsonDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return OptionalJsonDocumentReference(reference.doc(id)); + } + + @override + Future add(OptionalJson value) { + return reference + .add(value) + .then((ref) => OptionalJsonDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$OptionalJsonCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class OptionalJsonDocumentReference + extends + FirestoreDocumentReference { + factory OptionalJsonDocumentReference( + DocumentReference reference, + ) = _$OptionalJsonDocumentReference; + + DocumentReference get reference; + + /// A reference to the [OptionalJsonCollectionReference] containing this document. + OptionalJsonCollectionReference get parent { + return _$OptionalJsonCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + OptionalJson model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + OptionalJson model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + OptionalJson model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({int value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + implements OptionalJsonDocumentReference { + _$OptionalJsonDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [OptionalJsonCollectionReference] containing this document. + OptionalJsonCollectionReference get parent { + return _$OptionalJsonCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(OptionalJsonDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(OptionalJsonDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(OptionalJsonDocumentSnapshot._); + } + + Future set( + OptionalJson model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ..._$OptionalJsonToJson(model), + if (valueFieldValue != null) + _$OptionalJsonFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + OptionalJson model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ..._$OptionalJsonToJson(model), + if (valueFieldValue != null) + _$OptionalJsonFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + OptionalJson model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ..._$OptionalJsonToJson(model), + if (valueFieldValue != null) + _$OptionalJsonFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class OptionalJsonQuery + implements QueryReference { + @override + OptionalJsonQuery limit(int limit); + + @override + OptionalJsonQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + OptionalJsonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + OptionalJsonQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + OptionalJsonQuery whereValue({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + OptionalJsonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + OptionalJsonDocumentSnapshot? startAtDocument, + OptionalJsonDocumentSnapshot? endAtDocument, + OptionalJsonDocumentSnapshot? endBeforeDocument, + OptionalJsonDocumentSnapshot? startAfterDocument, + }); + + OptionalJsonQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + OptionalJsonDocumentSnapshot? startAtDocument, + OptionalJsonDocumentSnapshot? endAtDocument, + OptionalJsonDocumentSnapshot? endBeforeDocument, + OptionalJsonDocumentSnapshot? startAfterDocument, + }); + + OptionalJsonQuery orderByValue({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + OptionalJsonDocumentSnapshot? startAtDocument, + OptionalJsonDocumentSnapshot? endAtDocument, + OptionalJsonDocumentSnapshot? endBeforeDocument, + OptionalJsonDocumentSnapshot? startAfterDocument, + }); +} + +class _$OptionalJsonQuery + extends QueryReference + implements OptionalJsonQuery { + _$OptionalJsonQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + OptionalJsonQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(OptionalJsonQuerySnapshot._fromQuerySnapshot); + } + + @override + OptionalJsonQuery limit(int limit) { + return _$OptionalJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + OptionalJsonQuery limitToLast(int limit) { + return _$OptionalJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + OptionalJsonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$OptionalJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + OptionalJsonQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$OptionalJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + OptionalJsonQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$OptionalJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$OptionalJsonFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$OptionalJsonPerFieldToJson.value(isEqualTo as int) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$OptionalJsonPerFieldToJson.value(isNotEqualTo as int) + : null, + isLessThan: isLessThan != null + ? _$OptionalJsonPerFieldToJson.value(isLessThan as int) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$OptionalJsonPerFieldToJson.value(isLessThanOrEqualTo as int) + : null, + isGreaterThan: isGreaterThan != null + ? _$OptionalJsonPerFieldToJson.value(isGreaterThan as int) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$OptionalJsonPerFieldToJson.value(isGreaterThanOrEqualTo as int) + : null, + whereIn: whereIn?.map((e) => _$OptionalJsonPerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map( + (e) => _$OptionalJsonPerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + OptionalJsonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + OptionalJsonDocumentSnapshot? startAtDocument, + OptionalJsonDocumentSnapshot? endAtDocument, + OptionalJsonDocumentSnapshot? endBeforeDocument, + OptionalJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$OptionalJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + OptionalJsonQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + OptionalJsonDocumentSnapshot? startAtDocument, + OptionalJsonDocumentSnapshot? endAtDocument, + OptionalJsonDocumentSnapshot? endBeforeDocument, + OptionalJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$OptionalJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + OptionalJsonQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + OptionalJsonDocumentSnapshot? startAtDocument, + OptionalJsonDocumentSnapshot? endAtDocument, + OptionalJsonDocumentSnapshot? endBeforeDocument, + OptionalJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$OptionalJsonFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$OptionalJsonPerFieldToJson.value(startAt as int), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$OptionalJsonPerFieldToJson.value(startAfter as int), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$OptionalJsonPerFieldToJson.value(endAt as int), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$OptionalJsonPerFieldToJson.value(endBefore as int), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$OptionalJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$OptionalJsonQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class OptionalJsonDocumentSnapshot + extends FirestoreDocumentSnapshot { + OptionalJsonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + OptionalJsonDocumentReference get reference { + return OptionalJsonDocumentReference(snapshot.reference); + } + + @override + final OptionalJson? data; +} + +class OptionalJsonQuerySnapshot + extends + FirestoreQuerySnapshot< + OptionalJson, + OptionalJsonQueryDocumentSnapshot + > { + OptionalJsonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory OptionalJsonQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(OptionalJsonQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, OptionalJsonDocumentSnapshot._); + }).toList(); + + return OptionalJsonQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + OptionalJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class OptionalJsonQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements OptionalJsonDocumentSnapshot { + OptionalJsonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final OptionalJson data; + + @override + OptionalJsonDocumentReference get reference { + return OptionalJsonDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class MixedJsonCollectionReference + implements + MixedJsonQuery, + FirestoreCollectionReference { + factory MixedJsonCollectionReference([FirebaseFirestore? firestore]) = + _$MixedJsonCollectionReference; + + static MixedJson fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return MixedJson.fromJson(snapshot.data()!); + } + + static Map toFirestore( + MixedJson value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + MixedJsonDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(MixedJson value); +} + +class _$MixedJsonCollectionReference extends _$MixedJsonQuery + implements MixedJsonCollectionReference { + factory _$MixedJsonCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$MixedJsonCollectionReference._( + firestore + .collection('root') + .withConverter( + fromFirestore: MixedJsonCollectionReference.fromFirestore, + toFirestore: MixedJsonCollectionReference.toFirestore, + ), + ); + } + + _$MixedJsonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + MixedJsonDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return MixedJsonDocumentReference(reference.doc(id)); + } + + @override + Future add(MixedJson value) { + return reference.add(value).then((ref) => MixedJsonDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$MixedJsonCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class MixedJsonDocumentReference + extends FirestoreDocumentReference { + factory MixedJsonDocumentReference(DocumentReference reference) = + _$MixedJsonDocumentReference; + + DocumentReference get reference; + + /// A reference to the [MixedJsonCollectionReference] containing this document. + MixedJsonCollectionReference get parent { + return _$MixedJsonCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + MixedJson model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + MixedJson model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + MixedJson model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({int value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + extends FirestoreDocumentReference + implements MixedJsonDocumentReference { + _$MixedJsonDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [MixedJsonCollectionReference] containing this document. + MixedJsonCollectionReference get parent { + return _$MixedJsonCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(MixedJsonDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(MixedJsonDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(MixedJsonDocumentSnapshot._); + } + + Future set( + MixedJson model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$MixedJsonFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + MixedJson model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$MixedJsonFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + MixedJson model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$MixedJsonFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class MixedJsonQuery + implements QueryReference { + @override + MixedJsonQuery limit(int limit); + + @override + MixedJsonQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + MixedJsonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MixedJsonQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + MixedJsonQuery whereValue({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + MixedJsonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + MixedJsonDocumentSnapshot? startAtDocument, + MixedJsonDocumentSnapshot? endAtDocument, + MixedJsonDocumentSnapshot? endBeforeDocument, + MixedJsonDocumentSnapshot? startAfterDocument, + }); + + MixedJsonQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + MixedJsonDocumentSnapshot? startAtDocument, + MixedJsonDocumentSnapshot? endAtDocument, + MixedJsonDocumentSnapshot? endBeforeDocument, + MixedJsonDocumentSnapshot? startAfterDocument, + }); + + MixedJsonQuery orderByValue({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + MixedJsonDocumentSnapshot? startAtDocument, + MixedJsonDocumentSnapshot? endAtDocument, + MixedJsonDocumentSnapshot? endBeforeDocument, + MixedJsonDocumentSnapshot? startAfterDocument, + }); +} + +class _$MixedJsonQuery extends QueryReference + implements MixedJsonQuery { + _$MixedJsonQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(MixedJsonQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(MixedJsonQuerySnapshot._fromQuerySnapshot); + } + + @override + MixedJsonQuery limit(int limit) { + return _$MixedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + MixedJsonQuery limitToLast(int limit) { + return _$MixedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + MixedJsonQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MixedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MixedJsonQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MixedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MixedJsonQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$MixedJsonQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$MixedJsonFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$MixedJsonPerFieldToJson.value(isEqualTo as int) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$MixedJsonPerFieldToJson.value(isNotEqualTo as int) + : null, + isLessThan: isLessThan != null + ? _$MixedJsonPerFieldToJson.value(isLessThan as int) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$MixedJsonPerFieldToJson.value(isLessThanOrEqualTo as int) + : null, + isGreaterThan: isGreaterThan != null + ? _$MixedJsonPerFieldToJson.value(isGreaterThan as int) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$MixedJsonPerFieldToJson.value(isGreaterThanOrEqualTo as int) + : null, + whereIn: whereIn?.map((e) => _$MixedJsonPerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map((e) => _$MixedJsonPerFieldToJson.value(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + MixedJsonQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MixedJsonDocumentSnapshot? startAtDocument, + MixedJsonDocumentSnapshot? endAtDocument, + MixedJsonDocumentSnapshot? endBeforeDocument, + MixedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MixedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MixedJsonQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MixedJsonDocumentSnapshot? startAtDocument, + MixedJsonDocumentSnapshot? endAtDocument, + MixedJsonDocumentSnapshot? endBeforeDocument, + MixedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MixedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + MixedJsonQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + MixedJsonDocumentSnapshot? startAtDocument, + MixedJsonDocumentSnapshot? endAtDocument, + MixedJsonDocumentSnapshot? endBeforeDocument, + MixedJsonDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$MixedJsonFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$MixedJsonPerFieldToJson.value(startAt as int), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$MixedJsonPerFieldToJson.value(startAfter as int), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$MixedJsonPerFieldToJson.value(endAt as int), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$MixedJsonPerFieldToJson.value(endBefore as int), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$MixedJsonQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$MixedJsonQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class MixedJsonDocumentSnapshot extends FirestoreDocumentSnapshot { + MixedJsonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + MixedJsonDocumentReference get reference { + return MixedJsonDocumentReference(snapshot.reference); + } + + @override + final MixedJson? data; +} + +class MixedJsonQuerySnapshot + extends FirestoreQuerySnapshot { + MixedJsonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory MixedJsonQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(MixedJsonQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, MixedJsonDocumentSnapshot._); + }).toList(); + + return MixedJsonQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + MixedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class MixedJsonQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements MixedJsonDocumentSnapshot { + MixedJsonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final MixedJson data; + + @override + MixedJsonDocumentReference get reference { + return MixedJsonDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class RootCollectionReference + implements + RootQuery, + FirestoreCollectionReference { + factory RootCollectionReference([FirebaseFirestore? firestore]) = + _$RootCollectionReference; + + static Root fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return Root.fromJson(snapshot.data()!); + } + + static Map toFirestore(Root value, SetOptions? options) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + RootDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Root value); +} + +class _$RootCollectionReference extends _$RootQuery + implements RootCollectionReference { + factory _$RootCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$RootCollectionReference._( + firestore + .collection('root') + .withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + _$RootCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + RootDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return RootDocumentReference(reference.doc(id)); + } + + @override + Future add(Root value) { + return reference.add(value).then((ref) => RootDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$RootCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class RootDocumentReference + extends FirestoreDocumentReference { + factory RootDocumentReference(DocumentReference reference) = + _$RootDocumentReference; + + DocumentReference get reference; + + /// A reference to the [RootCollectionReference] containing this document. + RootCollectionReference get parent { + return _$RootCollectionReference(reference.firestore); + } + + late final SubCollectionReference sub = _$SubCollectionReference(reference); + + late final AsCamelCaseCollectionReference asCamelCase = + _$AsCamelCaseCollectionReference(reference); + + late final CustomSubNameCollectionReference thisIsACustomName = + _$CustomSubNameCollectionReference(reference); + + late final ThisIsACustomPrefixCollectionReference customClassPrefix = + _$ThisIsACustomPrefixCollectionReference(reference); + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Root model, { + SetOptions? options, + FieldValue nonNullableFieldValue, + FieldValue nullableFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Root model, { + SetOptions? options, + FieldValue nonNullableFieldValue, + FieldValue nullableFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Root model, { + SetOptions? options, + FieldValue nonNullableFieldValue, + FieldValue nullableFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String nonNullable, + FieldValue nonNullableFieldValue, + int? nullable, + FieldValue nullableFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String nonNullable, + FieldValue nonNullableFieldValue, + 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 + extends FirestoreDocumentReference + implements RootDocumentReference { + _$RootDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [RootCollectionReference] containing this document. + RootCollectionReference get parent { + return _$RootCollectionReference(reference.firestore); + } + + late final SubCollectionReference sub = _$SubCollectionReference(reference); + + late final AsCamelCaseCollectionReference asCamelCase = + _$AsCamelCaseCollectionReference(reference); + + late final CustomSubNameCollectionReference thisIsACustomName = + _$CustomSubNameCollectionReference(reference); + + late final ThisIsACustomPrefixCollectionReference customClassPrefix = + _$ThisIsACustomPrefixCollectionReference(reference); + + @override + Stream snapshots() { + return reference.snapshots().map(RootDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(RootDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(RootDocumentSnapshot._); + } + + Future set( + Root model, { + SetOptions? options, + FieldValue? nonNullableFieldValue, + FieldValue? nullableFieldValue, + }) async { + final json = { + ...model.toJson(), + if (nonNullableFieldValue != null) + _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + + if (nullableFieldValue != null) + _$RootFieldMap['nullable']!: nullableFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Root model, { + SetOptions? options, + FieldValue? nonNullableFieldValue, + FieldValue? nullableFieldValue, + }) { + final json = { + ...model.toJson(), + if (nonNullableFieldValue != null) + _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + + if (nullableFieldValue != null) + _$RootFieldMap['nullable']!: nullableFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Root model, { + SetOptions? options, + FieldValue? nonNullableFieldValue, + FieldValue? nullableFieldValue, + }) { + final json = { + ...model.toJson(), + if (nonNullableFieldValue != null) + _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + + if (nullableFieldValue != null) + _$RootFieldMap['nullable']!: nullableFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? nonNullable = _sentinel, + FieldValue? nonNullableFieldValue, + Object? nullable = _sentinel, + FieldValue? nullableFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class RootQuery implements QueryReference { + @override + RootQuery limit(int limit); + + @override + RootQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + RootQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + RootQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + RootQuery whereNonNullable({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + RootQuery whereNullable({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + RootQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + RootDocumentSnapshot? startAtDocument, + RootDocumentSnapshot? endAtDocument, + RootDocumentSnapshot? endBeforeDocument, + RootDocumentSnapshot? startAfterDocument, + }); + + RootQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + RootDocumentSnapshot? startAtDocument, + RootDocumentSnapshot? endAtDocument, + RootDocumentSnapshot? endBeforeDocument, + RootDocumentSnapshot? startAfterDocument, + }); + + RootQuery orderByNonNullable({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + RootDocumentSnapshot? startAtDocument, + RootDocumentSnapshot? endAtDocument, + RootDocumentSnapshot? endBeforeDocument, + RootDocumentSnapshot? startAfterDocument, + }); + + RootQuery orderByNullable({ + bool descending = false, + int? startAt, + int? startAfter, + int? endAt, + int? endBefore, + RootDocumentSnapshot? startAtDocument, + RootDocumentSnapshot? endAtDocument, + RootDocumentSnapshot? endBeforeDocument, + RootDocumentSnapshot? startAfterDocument, + }); +} + +class _$RootQuery extends QueryReference + implements RootQuery { + _$RootQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(RootQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(RootQuerySnapshot._fromQuerySnapshot); + } + + @override + RootQuery limit(int limit) { + return _$RootQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + RootQuery limitToLast(int limit) { + return _$RootQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + RootQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$RootQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + RootQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$RootQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + RootQuery whereNonNullable({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$RootQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$RootFieldMap['nonNullable']!, + isEqualTo: isEqualTo != _sentinel + ? _$RootPerFieldToJson.nonNullable(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$RootPerFieldToJson.nonNullable(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$RootPerFieldToJson.nonNullable(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$RootPerFieldToJson.nonNullable(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$RootPerFieldToJson.nonNullable(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$RootPerFieldToJson.nonNullable(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$RootPerFieldToJson.nonNullable(e)), + whereNotIn: whereNotIn?.map((e) => _$RootPerFieldToJson.nonNullable(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + RootQuery whereNullable({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$RootQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$RootFieldMap['nullable']!, + isEqualTo: isEqualTo != _sentinel + ? _$RootPerFieldToJson.nullable(isEqualTo as int?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$RootPerFieldToJson.nullable(isNotEqualTo as int?) + : null, + isLessThan: isLessThan != null + ? _$RootPerFieldToJson.nullable(isLessThan as int?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$RootPerFieldToJson.nullable(isLessThanOrEqualTo as int?) + : null, + isGreaterThan: isGreaterThan != null + ? _$RootPerFieldToJson.nullable(isGreaterThan as int?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$RootPerFieldToJson.nullable(isGreaterThanOrEqualTo as int?) + : null, + whereIn: whereIn?.map((e) => _$RootPerFieldToJson.nullable(e)), + whereNotIn: whereNotIn?.map((e) => _$RootPerFieldToJson.nullable(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + RootQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + RootDocumentSnapshot? startAtDocument, + RootDocumentSnapshot? endAtDocument, + RootDocumentSnapshot? endBeforeDocument, + RootDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$RootQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + RootQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + RootDocumentSnapshot? startAtDocument, + RootDocumentSnapshot? endAtDocument, + RootDocumentSnapshot? endBeforeDocument, + RootDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$RootQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + RootQuery orderByNonNullable({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + RootDocumentSnapshot? startAtDocument, + RootDocumentSnapshot? endAtDocument, + RootDocumentSnapshot? endBeforeDocument, + RootDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$RootFieldMap['nonNullable']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$RootPerFieldToJson.nonNullable(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$RootPerFieldToJson.nonNullable(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$RootPerFieldToJson.nonNullable(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$RootPerFieldToJson.nonNullable(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$RootQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + RootQuery orderByNullable({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + RootDocumentSnapshot? startAtDocument, + RootDocumentSnapshot? endAtDocument, + RootDocumentSnapshot? endBeforeDocument, + RootDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$RootFieldMap['nullable']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$RootPerFieldToJson.nullable(startAt as int?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$RootPerFieldToJson.nullable(startAfter as int?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$RootPerFieldToJson.nullable(endAt as int?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$RootPerFieldToJson.nullable(endBefore as int?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$RootQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$RootQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class RootDocumentSnapshot extends FirestoreDocumentSnapshot { + RootDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + RootDocumentReference get reference { + return RootDocumentReference(snapshot.reference); + } + + @override + final Root? data; +} + +class RootQuerySnapshot + extends FirestoreQuerySnapshot { + RootQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory RootQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { + final docs = snapshot.docs.map(RootQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, RootDocumentSnapshot._); + }).toList(); + + return RootQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange _decodeDocumentChange( + DocumentChange docChange, + RootDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class RootQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements RootDocumentSnapshot { + RootQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Root data; + + @override + RootDocumentReference get reference { + return RootDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class SubCollectionReference + implements SubQuery, FirestoreCollectionReference { + factory SubCollectionReference(DocumentReference parent) = + _$SubCollectionReference; + + static Sub fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return Sub.fromJson(snapshot.data()!); + } + + static Map toFirestore(Sub value, SetOptions? options) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + /// A reference to the containing [RootDocumentReference] if this is a subcollection. + RootDocumentReference get parent; + + @override + SubDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(Sub value); +} + +class _$SubCollectionReference extends _$SubQuery + implements SubCollectionReference { + factory _$SubCollectionReference(DocumentReference parent) { + return _$SubCollectionReference._( + RootDocumentReference(parent), + parent + .collection('sub') + .withConverter( + fromFirestore: SubCollectionReference.fromFirestore, + toFirestore: SubCollectionReference.toFirestore, + ), + ); + } + + _$SubCollectionReference._(this.parent, CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + @override + final RootDocumentReference parent; + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + SubDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return SubDocumentReference(reference.doc(id)); + } + + @override + Future add(Sub value) { + return reference.add(value).then((ref) => SubDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$SubCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class SubDocumentReference + extends FirestoreDocumentReference { + factory SubDocumentReference(DocumentReference reference) = + _$SubDocumentReference; + + DocumentReference get reference; + + /// A reference to the [SubCollectionReference] containing this document. + SubCollectionReference get parent { + return _$SubCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + Sub model, { + SetOptions? options, + FieldValue nonNullableFieldValue, + FieldValue nullableFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + Sub model, { + SetOptions? options, + FieldValue nonNullableFieldValue, + FieldValue nullableFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + Sub model, { + SetOptions? options, + FieldValue nonNullableFieldValue, + FieldValue nullableFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + String nonNullable, + FieldValue nonNullableFieldValue, + int? nullable, + FieldValue nullableFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + String nonNullable, + FieldValue nonNullableFieldValue, + 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 + extends FirestoreDocumentReference + implements SubDocumentReference { + _$SubDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [SubCollectionReference] containing this document. + SubCollectionReference get parent { + return _$SubCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots() { + return reference.snapshots().map(SubDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(SubDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(SubDocumentSnapshot._); + } + + Future set( + Sub model, { + SetOptions? options, + FieldValue? nonNullableFieldValue, + FieldValue? nullableFieldValue, + }) async { + final json = { + ...model.toJson(), + if (nonNullableFieldValue != null) + _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + + if (nullableFieldValue != null) + _$SubFieldMap['nullable']!: nullableFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + Sub model, { + SetOptions? options, + FieldValue? nonNullableFieldValue, + FieldValue? nullableFieldValue, + }) { + final json = { + ...model.toJson(), + if (nonNullableFieldValue != null) + _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + + if (nullableFieldValue != null) + _$SubFieldMap['nullable']!: nullableFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + Sub model, { + SetOptions? options, + FieldValue? nonNullableFieldValue, + FieldValue? nullableFieldValue, + }) { + final json = { + ...model.toJson(), + if (nonNullableFieldValue != null) + _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + + if (nullableFieldValue != null) + _$SubFieldMap['nullable']!: nullableFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? nonNullable = _sentinel, + FieldValue? nonNullableFieldValue, + Object? nullable = _sentinel, + FieldValue? nullableFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class SubQuery implements QueryReference { + @override + SubQuery limit(int limit); + + @override + SubQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + SubQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SubQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SubQuery whereNonNullable({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SubQuery whereNullable({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + SubQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + SubDocumentSnapshot? startAtDocument, + SubDocumentSnapshot? endAtDocument, + SubDocumentSnapshot? endBeforeDocument, + SubDocumentSnapshot? startAfterDocument, + }); + + SubQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + SubDocumentSnapshot? startAtDocument, + SubDocumentSnapshot? endAtDocument, + SubDocumentSnapshot? endBeforeDocument, + SubDocumentSnapshot? startAfterDocument, + }); + + SubQuery orderByNonNullable({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + SubDocumentSnapshot? startAtDocument, + SubDocumentSnapshot? endAtDocument, + SubDocumentSnapshot? endBeforeDocument, + SubDocumentSnapshot? startAfterDocument, + }); + + SubQuery orderByNullable({ + bool descending = false, + int? startAt, + int? startAfter, + int? endAt, + int? endBefore, + SubDocumentSnapshot? startAtDocument, + SubDocumentSnapshot? endAtDocument, + SubDocumentSnapshot? endBeforeDocument, + SubDocumentSnapshot? startAfterDocument, + }); +} + +class _$SubQuery extends QueryReference + implements SubQuery { + _$SubQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(SubQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(SubQuerySnapshot._fromQuerySnapshot); + } + + @override + SubQuery limit(int limit) { + return _$SubQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + SubQuery limitToLast(int limit) { + return _$SubQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + SubQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SubQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SubQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SubQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SubQuery whereNonNullable({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SubQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$SubFieldMap['nonNullable']!, + isEqualTo: isEqualTo != _sentinel + ? _$SubPerFieldToJson.nonNullable(isEqualTo as String) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$SubPerFieldToJson.nonNullable(isNotEqualTo as String) + : null, + isLessThan: isLessThan != null + ? _$SubPerFieldToJson.nonNullable(isLessThan as String) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$SubPerFieldToJson.nonNullable(isLessThanOrEqualTo as String) + : null, + isGreaterThan: isGreaterThan != null + ? _$SubPerFieldToJson.nonNullable(isGreaterThan as String) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$SubPerFieldToJson.nonNullable(isGreaterThanOrEqualTo as String) + : null, + whereIn: whereIn?.map((e) => _$SubPerFieldToJson.nonNullable(e)), + whereNotIn: whereNotIn?.map((e) => _$SubPerFieldToJson.nonNullable(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SubQuery whereNullable({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SubQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$SubFieldMap['nullable']!, + isEqualTo: isEqualTo != _sentinel + ? _$SubPerFieldToJson.nullable(isEqualTo as int?) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$SubPerFieldToJson.nullable(isNotEqualTo as int?) + : null, + isLessThan: isLessThan != null + ? _$SubPerFieldToJson.nullable(isLessThan as int?) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$SubPerFieldToJson.nullable(isLessThanOrEqualTo as int?) + : null, + isGreaterThan: isGreaterThan != null + ? _$SubPerFieldToJson.nullable(isGreaterThan as int?) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$SubPerFieldToJson.nullable(isGreaterThanOrEqualTo as int?) + : null, + whereIn: whereIn?.map((e) => _$SubPerFieldToJson.nullable(e)), + whereNotIn: whereNotIn?.map((e) => _$SubPerFieldToJson.nullable(e)), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SubQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SubDocumentSnapshot? startAtDocument, + SubDocumentSnapshot? endAtDocument, + SubDocumentSnapshot? endBeforeDocument, + SubDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SubQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SubQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SubDocumentSnapshot? startAtDocument, + SubDocumentSnapshot? endAtDocument, + SubDocumentSnapshot? endBeforeDocument, + SubDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SubQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SubQuery orderByNonNullable({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SubDocumentSnapshot? startAtDocument, + SubDocumentSnapshot? endAtDocument, + SubDocumentSnapshot? endBeforeDocument, + SubDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$SubFieldMap['nonNullable']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$SubPerFieldToJson.nonNullable(startAt as String), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$SubPerFieldToJson.nonNullable(startAfter as String), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$SubPerFieldToJson.nonNullable(endAt as String), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$SubPerFieldToJson.nonNullable(endBefore as String), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SubQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SubQuery orderByNullable({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SubDocumentSnapshot? startAtDocument, + SubDocumentSnapshot? endAtDocument, + SubDocumentSnapshot? endBeforeDocument, + SubDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$SubFieldMap['nullable']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$SubPerFieldToJson.nullable(startAt as int?), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$SubPerFieldToJson.nullable(startAfter as int?), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$SubPerFieldToJson.nullable(endAt as int?), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$SubPerFieldToJson.nullable(endBefore as int?), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SubQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$SubQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class SubDocumentSnapshot extends FirestoreDocumentSnapshot { + SubDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + SubDocumentReference get reference { + return SubDocumentReference(snapshot.reference); + } + + @override + final Sub? data; +} + +class SubQuerySnapshot + extends FirestoreQuerySnapshot { + SubQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory SubQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { + final docs = snapshot.docs.map(SubQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, SubDocumentSnapshot._); + }).toList(); + + return SubQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange _decodeDocumentChange( + DocumentChange docChange, + SubDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class SubQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements SubDocumentSnapshot { + SubQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final Sub data; + + @override + SubDocumentReference get reference { + return SubDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class AsCamelCaseCollectionReference + implements + AsCamelCaseQuery, + FirestoreCollectionReference { + factory AsCamelCaseCollectionReference(DocumentReference parent) = + _$AsCamelCaseCollectionReference; + + static AsCamelCase fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return AsCamelCase.fromJson(snapshot.data()!); + } + + static Map toFirestore( + AsCamelCase value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + /// A reference to the containing [RootDocumentReference] if this is a subcollection. + RootDocumentReference get parent; + + @override + AsCamelCaseDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(AsCamelCase value); +} + +class _$AsCamelCaseCollectionReference extends _$AsCamelCaseQuery + implements AsCamelCaseCollectionReference { + factory _$AsCamelCaseCollectionReference(DocumentReference parent) { + return _$AsCamelCaseCollectionReference._( + RootDocumentReference(parent), + parent + .collection('as-camel-case') + .withConverter( + fromFirestore: AsCamelCaseCollectionReference.fromFirestore, + toFirestore: AsCamelCaseCollectionReference.toFirestore, + ), + ); + } + + _$AsCamelCaseCollectionReference._( + this.parent, + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + @override + final RootDocumentReference parent; + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + AsCamelCaseDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return AsCamelCaseDocumentReference(reference.doc(id)); + } + + @override + Future add(AsCamelCase value) { + return reference + .add(value) + .then((ref) => AsCamelCaseDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$AsCamelCaseCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class AsCamelCaseDocumentReference + extends + FirestoreDocumentReference { + factory AsCamelCaseDocumentReference( + DocumentReference reference, + ) = _$AsCamelCaseDocumentReference; + + DocumentReference get reference; + + /// A reference to the [AsCamelCaseCollectionReference] containing this document. + AsCamelCaseCollectionReference get parent { + return _$AsCamelCaseCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + AsCamelCase model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + AsCamelCase model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + AsCamelCase model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({num value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + extends FirestoreDocumentReference + implements AsCamelCaseDocumentReference { + _$AsCamelCaseDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [AsCamelCaseCollectionReference] containing this document. + AsCamelCaseCollectionReference get parent { + return _$AsCamelCaseCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots() { + return reference.snapshots().map(AsCamelCaseDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(AsCamelCaseDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(AsCamelCaseDocumentSnapshot._); + } + + Future set( + AsCamelCase model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$AsCamelCaseFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + AsCamelCase model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$AsCamelCaseFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + AsCamelCase model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$AsCamelCaseFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class AsCamelCaseQuery + implements QueryReference { + @override + AsCamelCaseQuery limit(int limit); + + @override + AsCamelCaseQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + AsCamelCaseQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + AsCamelCaseQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + AsCamelCaseQuery whereValue({ + num? isEqualTo, + num? isNotEqualTo, + num? isLessThan, + num? isLessThanOrEqualTo, + num? isGreaterThan, + num? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + AsCamelCaseQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + AsCamelCaseDocumentSnapshot? startAtDocument, + AsCamelCaseDocumentSnapshot? endAtDocument, + AsCamelCaseDocumentSnapshot? endBeforeDocument, + AsCamelCaseDocumentSnapshot? startAfterDocument, + }); + + AsCamelCaseQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + AsCamelCaseDocumentSnapshot? startAtDocument, + AsCamelCaseDocumentSnapshot? endAtDocument, + AsCamelCaseDocumentSnapshot? endBeforeDocument, + AsCamelCaseDocumentSnapshot? startAfterDocument, + }); + + AsCamelCaseQuery orderByValue({ + bool descending = false, + num startAt, + num startAfter, + num endAt, + num endBefore, + AsCamelCaseDocumentSnapshot? startAtDocument, + AsCamelCaseDocumentSnapshot? endAtDocument, + AsCamelCaseDocumentSnapshot? endBeforeDocument, + AsCamelCaseDocumentSnapshot? startAfterDocument, + }); +} + +class _$AsCamelCaseQuery + extends QueryReference + implements AsCamelCaseQuery { + _$AsCamelCaseQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + AsCamelCaseQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(AsCamelCaseQuerySnapshot._fromQuerySnapshot); + } + + @override + AsCamelCaseQuery limit(int limit) { + return _$AsCamelCaseQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + AsCamelCaseQuery limitToLast(int limit) { + return _$AsCamelCaseQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + AsCamelCaseQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$AsCamelCaseQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + AsCamelCaseQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$AsCamelCaseQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + AsCamelCaseQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$AsCamelCaseQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$AsCamelCaseFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$AsCamelCasePerFieldToJson.value(isEqualTo as num) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$AsCamelCasePerFieldToJson.value(isNotEqualTo as num) + : null, + isLessThan: isLessThan != null + ? _$AsCamelCasePerFieldToJson.value(isLessThan as num) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$AsCamelCasePerFieldToJson.value(isLessThanOrEqualTo as num) + : null, + isGreaterThan: isGreaterThan != null + ? _$AsCamelCasePerFieldToJson.value(isGreaterThan as num) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$AsCamelCasePerFieldToJson.value(isGreaterThanOrEqualTo as num) + : null, + whereIn: whereIn?.map((e) => _$AsCamelCasePerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map( + (e) => _$AsCamelCasePerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + AsCamelCaseQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + AsCamelCaseDocumentSnapshot? startAtDocument, + AsCamelCaseDocumentSnapshot? endAtDocument, + AsCamelCaseDocumentSnapshot? endBeforeDocument, + AsCamelCaseDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$AsCamelCaseQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + AsCamelCaseQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + AsCamelCaseDocumentSnapshot? startAtDocument, + AsCamelCaseDocumentSnapshot? endAtDocument, + AsCamelCaseDocumentSnapshot? endBeforeDocument, + AsCamelCaseDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$AsCamelCaseQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + AsCamelCaseQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + AsCamelCaseDocumentSnapshot? startAtDocument, + AsCamelCaseDocumentSnapshot? endAtDocument, + AsCamelCaseDocumentSnapshot? endBeforeDocument, + AsCamelCaseDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$AsCamelCaseFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$AsCamelCasePerFieldToJson.value(startAt as num), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$AsCamelCasePerFieldToJson.value(startAfter as num), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$AsCamelCasePerFieldToJson.value(endAt as num), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$AsCamelCasePerFieldToJson.value(endBefore as num), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$AsCamelCaseQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$AsCamelCaseQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class AsCamelCaseDocumentSnapshot + extends FirestoreDocumentSnapshot { + AsCamelCaseDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + AsCamelCaseDocumentReference get reference { + return AsCamelCaseDocumentReference(snapshot.reference); + } + + @override + final AsCamelCase? data; +} + +class AsCamelCaseQuerySnapshot + extends + FirestoreQuerySnapshot { + AsCamelCaseQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory AsCamelCaseQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(AsCamelCaseQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, AsCamelCaseDocumentSnapshot._); + }).toList(); + + return AsCamelCaseQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + AsCamelCaseDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class AsCamelCaseQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements AsCamelCaseDocumentSnapshot { + AsCamelCaseQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final AsCamelCase data; + + @override + AsCamelCaseDocumentReference get reference { + return AsCamelCaseDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class CustomSubNameCollectionReference + implements + CustomSubNameQuery, + FirestoreCollectionReference< + CustomSubName, + CustomSubNameQuerySnapshot + > { + factory CustomSubNameCollectionReference(DocumentReference parent) = + _$CustomSubNameCollectionReference; + + static CustomSubName fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return CustomSubName.fromJson(snapshot.data()!); + } + + static Map toFirestore( + CustomSubName value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + /// A reference to the containing [RootDocumentReference] if this is a subcollection. + RootDocumentReference get parent; + + @override + CustomSubNameDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(CustomSubName value); +} + +class _$CustomSubNameCollectionReference extends _$CustomSubNameQuery + implements CustomSubNameCollectionReference { + factory _$CustomSubNameCollectionReference(DocumentReference parent) { + return _$CustomSubNameCollectionReference._( + RootDocumentReference(parent), + parent + .collection('custom-sub-name') + .withConverter( + fromFirestore: CustomSubNameCollectionReference.fromFirestore, + toFirestore: CustomSubNameCollectionReference.toFirestore, + ), + ); + } + + _$CustomSubNameCollectionReference._( + this.parent, + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + @override + final RootDocumentReference parent; + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + CustomSubNameDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return CustomSubNameDocumentReference(reference.doc(id)); + } + + @override + Future add(CustomSubName value) { + return reference + .add(value) + .then((ref) => CustomSubNameDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$CustomSubNameCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class CustomSubNameDocumentReference + extends + FirestoreDocumentReference< + CustomSubName, + CustomSubNameDocumentSnapshot + > { + factory CustomSubNameDocumentReference( + DocumentReference reference, + ) = _$CustomSubNameDocumentReference; + + DocumentReference get reference; + + /// A reference to the [CustomSubNameCollectionReference] containing this document. + CustomSubNameCollectionReference get parent { + return _$CustomSubNameCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + CustomSubName model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + CustomSubName model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + CustomSubName model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({num value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + implements CustomSubNameDocumentReference { + _$CustomSubNameDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [CustomSubNameCollectionReference] containing this document. + CustomSubNameCollectionReference get parent { + return _$CustomSubNameCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots() { + return reference.snapshots().map(CustomSubNameDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(CustomSubNameDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(CustomSubNameDocumentSnapshot._); + } + + Future set( + CustomSubName model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$CustomSubNameFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + CustomSubName model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$CustomSubNameFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + CustomSubName model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$CustomSubNameFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class CustomSubNameQuery + implements QueryReference { + @override + CustomSubNameQuery limit(int limit); + + @override + CustomSubNameQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + CustomSubNameQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + CustomSubNameQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + CustomSubNameQuery whereValue({ + num? isEqualTo, + num? isNotEqualTo, + num? isLessThan, + num? isLessThanOrEqualTo, + num? isGreaterThan, + num? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + CustomSubNameQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + CustomSubNameDocumentSnapshot? startAtDocument, + CustomSubNameDocumentSnapshot? endAtDocument, + CustomSubNameDocumentSnapshot? endBeforeDocument, + CustomSubNameDocumentSnapshot? startAfterDocument, + }); + + CustomSubNameQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + CustomSubNameDocumentSnapshot? startAtDocument, + CustomSubNameDocumentSnapshot? endAtDocument, + CustomSubNameDocumentSnapshot? endBeforeDocument, + CustomSubNameDocumentSnapshot? startAfterDocument, + }); + + CustomSubNameQuery orderByValue({ + bool descending = false, + num startAt, + num startAfter, + num endAt, + num endBefore, + CustomSubNameDocumentSnapshot? startAtDocument, + CustomSubNameDocumentSnapshot? endAtDocument, + CustomSubNameDocumentSnapshot? endBeforeDocument, + CustomSubNameDocumentSnapshot? startAfterDocument, + }); +} + +class _$CustomSubNameQuery + extends QueryReference + implements CustomSubNameQuery { + _$CustomSubNameQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + CustomSubNameQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(CustomSubNameQuerySnapshot._fromQuerySnapshot); + } + + @override + CustomSubNameQuery limit(int limit) { + return _$CustomSubNameQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + CustomSubNameQuery limitToLast(int limit) { + return _$CustomSubNameQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + CustomSubNameQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$CustomSubNameQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + CustomSubNameQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$CustomSubNameQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + CustomSubNameQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$CustomSubNameQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$CustomSubNameFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$CustomSubNamePerFieldToJson.value(isEqualTo as num) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$CustomSubNamePerFieldToJson.value(isNotEqualTo as num) + : null, + isLessThan: isLessThan != null + ? _$CustomSubNamePerFieldToJson.value(isLessThan as num) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$CustomSubNamePerFieldToJson.value(isLessThanOrEqualTo as num) + : null, + isGreaterThan: isGreaterThan != null + ? _$CustomSubNamePerFieldToJson.value(isGreaterThan as num) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$CustomSubNamePerFieldToJson.value(isGreaterThanOrEqualTo as num) + : null, + whereIn: whereIn?.map((e) => _$CustomSubNamePerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map( + (e) => _$CustomSubNamePerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + CustomSubNameQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + CustomSubNameDocumentSnapshot? startAtDocument, + CustomSubNameDocumentSnapshot? endAtDocument, + CustomSubNameDocumentSnapshot? endBeforeDocument, + CustomSubNameDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$CustomSubNameQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + CustomSubNameQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + CustomSubNameDocumentSnapshot? startAtDocument, + CustomSubNameDocumentSnapshot? endAtDocument, + CustomSubNameDocumentSnapshot? endBeforeDocument, + CustomSubNameDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$CustomSubNameQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + CustomSubNameQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + CustomSubNameDocumentSnapshot? startAtDocument, + CustomSubNameDocumentSnapshot? endAtDocument, + CustomSubNameDocumentSnapshot? endBeforeDocument, + CustomSubNameDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$CustomSubNameFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$CustomSubNamePerFieldToJson.value(startAt as num), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$CustomSubNamePerFieldToJson.value(startAfter as num), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$CustomSubNamePerFieldToJson.value(endAt as num), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$CustomSubNamePerFieldToJson.value(endBefore as num), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$CustomSubNameQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$CustomSubNameQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class CustomSubNameDocumentSnapshot + extends FirestoreDocumentSnapshot { + CustomSubNameDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + CustomSubNameDocumentReference get reference { + return CustomSubNameDocumentReference(snapshot.reference); + } + + @override + final CustomSubName? data; +} + +class CustomSubNameQuerySnapshot + extends + FirestoreQuerySnapshot< + CustomSubName, + CustomSubNameQueryDocumentSnapshot + > { + CustomSubNameQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory CustomSubNameQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(CustomSubNameQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, CustomSubNameDocumentSnapshot._); + }).toList(); + + return CustomSubNameQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + CustomSubNameDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class CustomSubNameQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements CustomSubNameDocumentSnapshot { + CustomSubNameQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final CustomSubName data; + + @override + CustomSubNameDocumentReference get reference { + return CustomSubNameDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class ThisIsACustomPrefixCollectionReference + implements + ThisIsACustomPrefixQuery, + FirestoreCollectionReference< + CustomClassPrefix, + ThisIsACustomPrefixQuerySnapshot + > { + factory ThisIsACustomPrefixCollectionReference( + DocumentReference parent, + ) = _$ThisIsACustomPrefixCollectionReference; + + static CustomClassPrefix fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return CustomClassPrefix.fromJson(snapshot.data()!); + } + + static Map toFirestore( + CustomClassPrefix value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + /// A reference to the containing [RootDocumentReference] if this is a subcollection. + RootDocumentReference get parent; + + @override + ThisIsACustomPrefixDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(CustomClassPrefix value); +} + +class _$ThisIsACustomPrefixCollectionReference + extends _$ThisIsACustomPrefixQuery + implements ThisIsACustomPrefixCollectionReference { + factory _$ThisIsACustomPrefixCollectionReference( + DocumentReference parent, + ) { + return _$ThisIsACustomPrefixCollectionReference._( + RootDocumentReference(parent), + parent + .collection('custom-class-prefix') + .withConverter( + fromFirestore: ThisIsACustomPrefixCollectionReference.fromFirestore, + toFirestore: ThisIsACustomPrefixCollectionReference.toFirestore, + ), + ); + } + + _$ThisIsACustomPrefixCollectionReference._( + this.parent, + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + @override + final RootDocumentReference parent; + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + ThisIsACustomPrefixDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return ThisIsACustomPrefixDocumentReference(reference.doc(id)); + } + + @override + Future add(CustomClassPrefix value) { + return reference + .add(value) + .then((ref) => ThisIsACustomPrefixDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$ThisIsACustomPrefixCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class ThisIsACustomPrefixDocumentReference + extends + FirestoreDocumentReference< + CustomClassPrefix, + ThisIsACustomPrefixDocumentSnapshot + > { + factory ThisIsACustomPrefixDocumentReference( + DocumentReference reference, + ) = _$ThisIsACustomPrefixDocumentReference; + + DocumentReference get reference; + + /// A reference to the [ThisIsACustomPrefixCollectionReference] containing this document. + ThisIsACustomPrefixCollectionReference get parent { + return _$ThisIsACustomPrefixCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + CustomClassPrefix model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + CustomClassPrefix model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + CustomClassPrefix model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({num value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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< + CustomClassPrefix, + ThisIsACustomPrefixDocumentSnapshot + > + implements ThisIsACustomPrefixDocumentReference { + _$ThisIsACustomPrefixDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [ThisIsACustomPrefixCollectionReference] containing this document. + ThisIsACustomPrefixCollectionReference get parent { + return _$ThisIsACustomPrefixCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: RootCollectionReference.fromFirestore, + toFirestore: RootCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots() { + return reference.snapshots().map(ThisIsACustomPrefixDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(ThisIsACustomPrefixDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction + .get(reference) + .then(ThisIsACustomPrefixDocumentSnapshot._); + } + + Future set( + CustomClassPrefix model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$CustomClassPrefixFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + CustomClassPrefix model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$CustomClassPrefixFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + CustomClassPrefix model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$CustomClassPrefixFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class ThisIsACustomPrefixQuery + implements + QueryReference { + @override + ThisIsACustomPrefixQuery limit(int limit); + + @override + ThisIsACustomPrefixQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + ThisIsACustomPrefixQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ThisIsACustomPrefixQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ThisIsACustomPrefixQuery whereValue({ + num? isEqualTo, + num? isNotEqualTo, + num? isLessThan, + num? isLessThanOrEqualTo, + num? isGreaterThan, + num? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + ThisIsACustomPrefixQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + ThisIsACustomPrefixDocumentSnapshot? startAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, + ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, + }); + + ThisIsACustomPrefixQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + ThisIsACustomPrefixDocumentSnapshot? startAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, + ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, + }); + + ThisIsACustomPrefixQuery orderByValue({ + bool descending = false, + num startAt, + num startAfter, + num endAt, + num endBefore, + ThisIsACustomPrefixDocumentSnapshot? startAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, + ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, + }); +} + +class _$ThisIsACustomPrefixQuery + extends QueryReference + implements ThisIsACustomPrefixQuery { + _$ThisIsACustomPrefixQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot); + } + + @override + ThisIsACustomPrefixQuery limit(int limit) { + return _$ThisIsACustomPrefixQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ThisIsACustomPrefixQuery limitToLast(int limit) { + return _$ThisIsACustomPrefixQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ThisIsACustomPrefixQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ThisIsACustomPrefixQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ThisIsACustomPrefixQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ThisIsACustomPrefixQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ThisIsACustomPrefixQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ThisIsACustomPrefixQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$CustomClassPrefixFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$CustomClassPrefixPerFieldToJson.value(isEqualTo as num) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$CustomClassPrefixPerFieldToJson.value(isNotEqualTo as num) + : null, + isLessThan: isLessThan != null + ? _$CustomClassPrefixPerFieldToJson.value(isLessThan as num) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$CustomClassPrefixPerFieldToJson.value( + isLessThanOrEqualTo as num, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$CustomClassPrefixPerFieldToJson.value(isGreaterThan as num) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$CustomClassPrefixPerFieldToJson.value( + isGreaterThanOrEqualTo as num, + ) + : null, + whereIn: whereIn?.map( + (e) => _$CustomClassPrefixPerFieldToJson.value(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$CustomClassPrefixPerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ThisIsACustomPrefixQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ThisIsACustomPrefixDocumentSnapshot? startAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, + ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ThisIsACustomPrefixQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ThisIsACustomPrefixQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ThisIsACustomPrefixDocumentSnapshot? startAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, + ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ThisIsACustomPrefixQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ThisIsACustomPrefixQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ThisIsACustomPrefixDocumentSnapshot? startAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endAtDocument, + ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, + ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$CustomClassPrefixFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$CustomClassPrefixPerFieldToJson.value(startAt as num), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$CustomClassPrefixPerFieldToJson.value(startAfter as num), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$CustomClassPrefixPerFieldToJson.value(endAt as num), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$CustomClassPrefixPerFieldToJson.value(endBefore as num), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ThisIsACustomPrefixQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$ThisIsACustomPrefixQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class ThisIsACustomPrefixDocumentSnapshot + extends FirestoreDocumentSnapshot { + ThisIsACustomPrefixDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ThisIsACustomPrefixDocumentReference get reference { + return ThisIsACustomPrefixDocumentReference(snapshot.reference); + } + + @override + final CustomClassPrefix? data; +} + +class ThisIsACustomPrefixQuerySnapshot + extends + FirestoreQuerySnapshot< + CustomClassPrefix, + ThisIsACustomPrefixQueryDocumentSnapshot + > { + ThisIsACustomPrefixQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(ThisIsACustomPrefixQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange( + change, + ThisIsACustomPrefixDocumentSnapshot._, + ); + }).toList(); + + return ThisIsACustomPrefixQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ThisIsACustomPrefixDocumentSnapshot Function(DocumentSnapshot doc) + decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> + docChanges; +} + +class ThisIsACustomPrefixQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements ThisIsACustomPrefixDocumentSnapshot { + ThisIsACustomPrefixQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final CustomClassPrefix data; + + @override + ThisIsACustomPrefixDocumentReference get reference { + return ThisIsACustomPrefixDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class ExplicitPathCollectionReference + implements + ExplicitPathQuery, + FirestoreCollectionReference { + factory ExplicitPathCollectionReference([FirebaseFirestore? firestore]) = + _$ExplicitPathCollectionReference; + + static ExplicitPath fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return ExplicitPath.fromJson(snapshot.data()!); + } + + static Map toFirestore( + ExplicitPath value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + ExplicitPathDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(ExplicitPath value); +} + +class _$ExplicitPathCollectionReference extends _$ExplicitPathQuery + implements ExplicitPathCollectionReference { + factory _$ExplicitPathCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$ExplicitPathCollectionReference._( + firestore + .collection('root/doc/path') + .withConverter( + fromFirestore: ExplicitPathCollectionReference.fromFirestore, + toFirestore: ExplicitPathCollectionReference.toFirestore, + ), + ); + } + + _$ExplicitPathCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + ExplicitPathDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return ExplicitPathDocumentReference(reference.doc(id)); + } + + @override + Future add(ExplicitPath value) { + return reference + .add(value) + .then((ref) => ExplicitPathDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$ExplicitPathCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class ExplicitPathDocumentReference + extends + FirestoreDocumentReference { + factory ExplicitPathDocumentReference( + DocumentReference reference, + ) = _$ExplicitPathDocumentReference; + + DocumentReference get reference; + + /// A reference to the [ExplicitPathCollectionReference] containing this document. + ExplicitPathCollectionReference get parent { + return _$ExplicitPathCollectionReference(reference.firestore); + } + + late final ExplicitSubPathCollectionReference sub = + _$ExplicitSubPathCollectionReference(reference); + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + ExplicitPath model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + ExplicitPath model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + ExplicitPath model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({num value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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 + implements ExplicitPathDocumentReference { + _$ExplicitPathDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [ExplicitPathCollectionReference] containing this document. + ExplicitPathCollectionReference get parent { + return _$ExplicitPathCollectionReference(reference.firestore); + } + + late final ExplicitSubPathCollectionReference sub = + _$ExplicitSubPathCollectionReference(reference); + + @override + Stream snapshots() { + return reference.snapshots().map(ExplicitPathDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(ExplicitPathDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(ExplicitPathDocumentSnapshot._); + } + + Future set( + ExplicitPath model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$ExplicitPathFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + ExplicitPath model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$ExplicitPathFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + ExplicitPath model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$ExplicitPathFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class ExplicitPathQuery + implements QueryReference { + @override + ExplicitPathQuery limit(int limit); + + @override + ExplicitPathQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + ExplicitPathQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ExplicitPathQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ExplicitPathQuery whereValue({ + num? isEqualTo, + num? isNotEqualTo, + num? isLessThan, + num? isLessThanOrEqualTo, + num? isGreaterThan, + num? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + ExplicitPathQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + ExplicitPathDocumentSnapshot? startAtDocument, + ExplicitPathDocumentSnapshot? endAtDocument, + ExplicitPathDocumentSnapshot? endBeforeDocument, + ExplicitPathDocumentSnapshot? startAfterDocument, + }); + + ExplicitPathQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + ExplicitPathDocumentSnapshot? startAtDocument, + ExplicitPathDocumentSnapshot? endAtDocument, + ExplicitPathDocumentSnapshot? endBeforeDocument, + ExplicitPathDocumentSnapshot? startAfterDocument, + }); + + ExplicitPathQuery orderByValue({ + bool descending = false, + num startAt, + num startAfter, + num endAt, + num endBefore, + ExplicitPathDocumentSnapshot? startAtDocument, + ExplicitPathDocumentSnapshot? endAtDocument, + ExplicitPathDocumentSnapshot? endBeforeDocument, + ExplicitPathDocumentSnapshot? startAfterDocument, + }); +} + +class _$ExplicitPathQuery + extends QueryReference + implements ExplicitPathQuery { + _$ExplicitPathQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + ExplicitPathQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(ExplicitPathQuerySnapshot._fromQuerySnapshot); + } + + @override + ExplicitPathQuery limit(int limit) { + return _$ExplicitPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitPathQuery limitToLast(int limit) { + return _$ExplicitPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitPathQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ExplicitPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitPathQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ExplicitPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitPathQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ExplicitPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$ExplicitPathFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$ExplicitPathPerFieldToJson.value(isEqualTo as num) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$ExplicitPathPerFieldToJson.value(isNotEqualTo as num) + : null, + isLessThan: isLessThan != null + ? _$ExplicitPathPerFieldToJson.value(isLessThan as num) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$ExplicitPathPerFieldToJson.value(isLessThanOrEqualTo as num) + : null, + isGreaterThan: isGreaterThan != null + ? _$ExplicitPathPerFieldToJson.value(isGreaterThan as num) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$ExplicitPathPerFieldToJson.value(isGreaterThanOrEqualTo as num) + : null, + whereIn: whereIn?.map((e) => _$ExplicitPathPerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map( + (e) => _$ExplicitPathPerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitPathQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ExplicitPathDocumentSnapshot? startAtDocument, + ExplicitPathDocumentSnapshot? endAtDocument, + ExplicitPathDocumentSnapshot? endBeforeDocument, + ExplicitPathDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ExplicitPathQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ExplicitPathQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ExplicitPathDocumentSnapshot? startAtDocument, + ExplicitPathDocumentSnapshot? endAtDocument, + ExplicitPathDocumentSnapshot? endBeforeDocument, + ExplicitPathDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ExplicitPathQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ExplicitPathQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ExplicitPathDocumentSnapshot? startAtDocument, + ExplicitPathDocumentSnapshot? endAtDocument, + ExplicitPathDocumentSnapshot? endBeforeDocument, + ExplicitPathDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$ExplicitPathFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$ExplicitPathPerFieldToJson.value(startAt as num), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$ExplicitPathPerFieldToJson.value(startAfter as num), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$ExplicitPathPerFieldToJson.value(endAt as num), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$ExplicitPathPerFieldToJson.value(endBefore as num), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ExplicitPathQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$ExplicitPathQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class ExplicitPathDocumentSnapshot + extends FirestoreDocumentSnapshot { + ExplicitPathDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ExplicitPathDocumentReference get reference { + return ExplicitPathDocumentReference(snapshot.reference); + } + + @override + final ExplicitPath? data; +} + +class ExplicitPathQuerySnapshot + extends + FirestoreQuerySnapshot< + ExplicitPath, + ExplicitPathQueryDocumentSnapshot + > { + ExplicitPathQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory ExplicitPathQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(ExplicitPathQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, ExplicitPathDocumentSnapshot._); + }).toList(); + + return ExplicitPathQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ExplicitPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class ExplicitPathQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements ExplicitPathDocumentSnapshot { + ExplicitPathQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final ExplicitPath data; + + @override + ExplicitPathDocumentReference get reference { + return ExplicitPathDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class ExplicitSubPathCollectionReference + implements + ExplicitSubPathQuery, + FirestoreCollectionReference< + ExplicitSubPath, + ExplicitSubPathQuerySnapshot + > { + factory ExplicitSubPathCollectionReference( + DocumentReference parent, + ) = _$ExplicitSubPathCollectionReference; + + static ExplicitSubPath fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return ExplicitSubPath.fromJson(snapshot.data()!); + } + + static Map toFirestore( + ExplicitSubPath value, + SetOptions? options, + ) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + /// A reference to the containing [ExplicitPathDocumentReference] if this is a subcollection. + ExplicitPathDocumentReference get parent; + + @override + ExplicitSubPathDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(ExplicitSubPath value); +} + +class _$ExplicitSubPathCollectionReference extends _$ExplicitSubPathQuery + implements ExplicitSubPathCollectionReference { + factory _$ExplicitSubPathCollectionReference( + DocumentReference parent, + ) { + return _$ExplicitSubPathCollectionReference._( + ExplicitPathDocumentReference(parent), + parent + .collection('sub') + .withConverter( + fromFirestore: ExplicitSubPathCollectionReference.fromFirestore, + toFirestore: ExplicitSubPathCollectionReference.toFirestore, + ), + ); + } + + _$ExplicitSubPathCollectionReference._( + this.parent, + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); + + @override + final ExplicitPathDocumentReference parent; + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + ExplicitSubPathDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return ExplicitSubPathDocumentReference(reference.doc(id)); + } + + @override + Future add(ExplicitSubPath value) { + return reference + .add(value) + .then((ref) => ExplicitSubPathDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$ExplicitSubPathCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class ExplicitSubPathDocumentReference + extends + FirestoreDocumentReference< + ExplicitSubPath, + ExplicitSubPathDocumentSnapshot + > { + factory ExplicitSubPathDocumentReference( + DocumentReference reference, + ) = _$ExplicitSubPathDocumentReference; + + DocumentReference get reference; + + /// A reference to the [ExplicitSubPathCollectionReference] containing this document. + ExplicitSubPathCollectionReference get parent { + return _$ExplicitSubPathCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: ExplicitPathCollectionReference.fromFirestore, + toFirestore: ExplicitPathCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + ExplicitSubPath model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + ExplicitSubPath model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + ExplicitSubPath model, { + SetOptions? options, + FieldValue valueFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({num value, FieldValue valueFieldValue}); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + 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< + ExplicitSubPath, + ExplicitSubPathDocumentSnapshot + > + implements ExplicitSubPathDocumentReference { + _$ExplicitSubPathDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [ExplicitSubPathCollectionReference] containing this document. + ExplicitSubPathCollectionReference get parent { + return _$ExplicitSubPathCollectionReference( + reference.parent.parent!.withConverter( + fromFirestore: ExplicitPathCollectionReference.fromFirestore, + toFirestore: ExplicitPathCollectionReference.toFirestore, + ), + ); + } + + @override + Stream snapshots() { + return reference.snapshots().map(ExplicitSubPathDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(ExplicitSubPathDocumentSnapshot._); + } + + @override + Future transactionGet( + Transaction transaction, + ) { + return transaction.get(reference).then(ExplicitSubPathDocumentSnapshot._); + } + + Future set( + ExplicitSubPath model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) async { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$ExplicitSubPathFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + ExplicitSubPath model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$ExplicitSubPathFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + ExplicitSubPath model, { + SetOptions? options, + FieldValue? valueFieldValue, + }) { + final json = { + ...model.toJson(), + if (valueFieldValue != null) + _$ExplicitSubPathFieldMap['value']!: valueFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? value = _sentinel, + FieldValue? valueFieldValue, + }) async { + 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, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + 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, + }; + + 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 && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class ExplicitSubPathQuery + implements QueryReference { + @override + ExplicitSubPathQuery limit(int limit); + + @override + ExplicitSubPathQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + ExplicitSubPathQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ExplicitSubPathQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + ExplicitSubPathQuery whereValue({ + num? isEqualTo, + num? isNotEqualTo, + num? isLessThan, + num? isLessThanOrEqualTo, + num? isGreaterThan, + num? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + ExplicitSubPathQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + ExplicitSubPathDocumentSnapshot? startAtDocument, + ExplicitSubPathDocumentSnapshot? endAtDocument, + ExplicitSubPathDocumentSnapshot? endBeforeDocument, + ExplicitSubPathDocumentSnapshot? startAfterDocument, + }); + + ExplicitSubPathQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + ExplicitSubPathDocumentSnapshot? startAtDocument, + ExplicitSubPathDocumentSnapshot? endAtDocument, + ExplicitSubPathDocumentSnapshot? endBeforeDocument, + ExplicitSubPathDocumentSnapshot? startAfterDocument, + }); + + ExplicitSubPathQuery orderByValue({ + bool descending = false, + num startAt, + num startAfter, + num endAt, + num endBefore, + ExplicitSubPathDocumentSnapshot? startAtDocument, + ExplicitSubPathDocumentSnapshot? endAtDocument, + ExplicitSubPathDocumentSnapshot? endBeforeDocument, + ExplicitSubPathDocumentSnapshot? startAfterDocument, + }); +} + +class _$ExplicitSubPathQuery + extends QueryReference + implements ExplicitSubPathQuery { + _$ExplicitSubPathQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map( + ExplicitSubPathQuerySnapshot._fromQuerySnapshot, + ); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(ExplicitSubPathQuerySnapshot._fromQuerySnapshot); + } + + @override + ExplicitSubPathQuery limit(int limit) { + return _$ExplicitSubPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitSubPathQuery limitToLast(int limit) { + return _$ExplicitSubPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitSubPathQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ExplicitSubPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitSubPathQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ExplicitSubPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitSubPathQuery whereValue({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$ExplicitSubPathQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$ExplicitSubPathFieldMap['value']!, + isEqualTo: isEqualTo != _sentinel + ? _$ExplicitSubPathPerFieldToJson.value(isEqualTo as num) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$ExplicitSubPathPerFieldToJson.value(isNotEqualTo as num) + : null, + isLessThan: isLessThan != null + ? _$ExplicitSubPathPerFieldToJson.value(isLessThan as num) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$ExplicitSubPathPerFieldToJson.value(isLessThanOrEqualTo as num) + : null, + isGreaterThan: isGreaterThan != null + ? _$ExplicitSubPathPerFieldToJson.value(isGreaterThan as num) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$ExplicitSubPathPerFieldToJson.value( + isGreaterThanOrEqualTo as num, + ) + : null, + whereIn: whereIn?.map((e) => _$ExplicitSubPathPerFieldToJson.value(e)), + whereNotIn: whereNotIn?.map( + (e) => _$ExplicitSubPathPerFieldToJson.value(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + ExplicitSubPathQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ExplicitSubPathDocumentSnapshot? startAtDocument, + ExplicitSubPathDocumentSnapshot? endAtDocument, + ExplicitSubPathDocumentSnapshot? endBeforeDocument, + ExplicitSubPathDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ExplicitSubPathQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ExplicitSubPathQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ExplicitSubPathDocumentSnapshot? startAtDocument, + ExplicitSubPathDocumentSnapshot? endAtDocument, + ExplicitSubPathDocumentSnapshot? endBeforeDocument, + ExplicitSubPathDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ExplicitSubPathQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + ExplicitSubPathQuery orderByValue({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + ExplicitSubPathDocumentSnapshot? startAtDocument, + ExplicitSubPathDocumentSnapshot? endAtDocument, + ExplicitSubPathDocumentSnapshot? endBeforeDocument, + ExplicitSubPathDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$ExplicitSubPathFieldMap['value']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$ExplicitSubPathPerFieldToJson.value(startAt as num), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$ExplicitSubPathPerFieldToJson.value(startAfter as num), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$ExplicitSubPathPerFieldToJson.value(endAt as num), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$ExplicitSubPathPerFieldToJson.value(endBefore as num), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$ExplicitSubPathQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$ExplicitSubPathQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class ExplicitSubPathDocumentSnapshot + extends FirestoreDocumentSnapshot { + ExplicitSubPathDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + ExplicitSubPathDocumentReference get reference { + return ExplicitSubPathDocumentReference(snapshot.reference); + } + + @override + final ExplicitSubPath? data; +} + +class ExplicitSubPathQuerySnapshot + extends + FirestoreQuerySnapshot< + ExplicitSubPath, + ExplicitSubPathQueryDocumentSnapshot + > { + ExplicitSubPathQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory ExplicitSubPathQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs + .map(ExplicitSubPathQueryDocumentSnapshot._) + .toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, ExplicitSubPathDocumentSnapshot._); + }).toList(); + + return ExplicitSubPathQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + ExplicitSubPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> + docChanges; +} + +class ExplicitSubPathQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements ExplicitSubPathDocumentSnapshot { + ExplicitSubPathQueryDocumentSnapshot._(this.snapshot) + : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final ExplicitSubPath data; + + @override + ExplicitSubPathDocumentReference get reference { + return ExplicitSubPathDocumentReference(snapshot.reference); + } +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class SubClassCollectionReference + implements + SubClassQuery, + FirestoreCollectionReference { + factory SubClassCollectionReference([FirebaseFirestore? firestore]) = + _$SubClassCollectionReference; + + static SubClass fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return SubClass.fromJson(snapshot.data()!); + } + + static Map toFirestore(SubClass value, SetOptions? options) { + return value.toJson(); + } + + @override + CollectionReference get reference; + + @override + SubClassDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(SubClass value); +} + +class _$SubClassCollectionReference extends _$SubClassQuery + implements SubClassCollectionReference { + factory _$SubClassCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$SubClassCollectionReference._( + firestore + .collection('root') + .withConverter( + fromFirestore: SubClassCollectionReference.fromFirestore, + toFirestore: SubClassCollectionReference.toFirestore, + ), + ); + } + + _$SubClassCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + SubClassDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return SubClassDocumentReference(reference.doc(id)); + } + + @override + Future add(SubClass value) { + return reference.add(value).then((ref) => SubClassDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$SubClassCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class SubClassDocumentReference + extends FirestoreDocumentReference { + factory SubClassDocumentReference(DocumentReference reference) = + _$SubClassDocumentReference; + + DocumentReference get reference; + + /// A reference to the [SubClassCollectionReference] containing this document. + SubClassCollectionReference get parent { + return _$SubClassCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + /// Sets data on the document, overwriting any existing data. If the document + /// does not yet exist, it will be created. + /// + /// If [SetOptions] are provided, the data can be merged into an existing + /// document instead of overwriting. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + Future set( + SubClass model, { + SetOptions? options, + FieldValue instanceGetterFieldValue, + }); + + /// Writes to the document using the transaction API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void transactionSet( + Transaction transaction, + SubClass model, { + SetOptions? options, + FieldValue instanceGetterFieldValue, + }); + + /// Writes to the document using the batch API. + /// + /// If the document does not exist yet, it will be created. If you pass + /// [SetOptions], the provided data can be merged into the existing document. + /// + /// Any [FieldValue]s provided will replace the corresponding fields in the + /// [model] during serialization. + void batchSet( + WriteBatch batch, + SubClass model, { + SetOptions? options, + FieldValue instanceGetterFieldValue, + }); + + /// Updates data on the document. Data will be merged with any existing + /// document data. + /// + /// If no document exists yet, the update will fail. + Future update({ + int instanceGetter, + FieldValue instanceGetterFieldValue, + }); + + /// Updates fields in the current document using the transaction API. + /// + /// The update will fail if applied to a document that does not exist. + void transactionUpdate( + Transaction transaction, { + int instanceGetter, + FieldValue instanceGetterFieldValue, + }); + + /// 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 instanceGetter, + FieldValue instanceGetterFieldValue, + }); +} + +class _$SubClassDocumentReference + extends FirestoreDocumentReference + implements SubClassDocumentReference { + _$SubClassDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [SubClassCollectionReference] containing this document. + SubClassCollectionReference get parent { + return _$SubClassCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map(SubClassDocumentSnapshot._); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(SubClassDocumentSnapshot._); + } + + @override + Future transactionGet(Transaction transaction) { + return transaction.get(reference).then(SubClassDocumentSnapshot._); + } + + Future set( + SubClass model, { + SetOptions? options, + FieldValue? instanceGetterFieldValue, + }) async { + final json = { + ...model.toJson(), + if (instanceGetterFieldValue != null) + _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + return castedReference.set(json, options); + } + + void transactionSet( + Transaction transaction, + SubClass model, { + SetOptions? options, + FieldValue? instanceGetterFieldValue, + }) { + final json = { + ...model.toJson(), + if (instanceGetterFieldValue != null) + _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); + } + + void batchSet( + WriteBatch batch, + SubClass model, { + SetOptions? options, + FieldValue? instanceGetterFieldValue, + }) { + final json = { + ...model.toJson(), + if (instanceGetterFieldValue != null) + _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, + }; + + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); + } + + Future update({ + Object? instanceGetter = _sentinel, + FieldValue? instanceGetterFieldValue, + }) async { + assert( + instanceGetter == _sentinel || instanceGetterFieldValue == null, + "Cannot specify both instanceGetter and instanceGetterFieldValue", + ); + final json = { + if (instanceGetter != _sentinel) + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + + if (instanceGetterFieldValue != null) + _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, + }; + + return reference.update(json); + } + + void transactionUpdate( + Transaction transaction, { + Object? instanceGetter = _sentinel, + FieldValue? instanceGetterFieldValue, + }) { + assert( + instanceGetter == _sentinel || instanceGetterFieldValue == null, + "Cannot specify both instanceGetter and instanceGetterFieldValue", + ); + final json = { + if (instanceGetter != _sentinel) + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + + if (instanceGetterFieldValue != null) + _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, + }; + + transaction.update(reference, json); + } + + void batchUpdate( + WriteBatch batch, { + Object? instanceGetter = _sentinel, + FieldValue? instanceGetterFieldValue, + }) { + assert( + instanceGetter == _sentinel || instanceGetterFieldValue == null, + "Cannot specify both instanceGetter and instanceGetterFieldValue", + ); + final json = { + if (instanceGetter != _sentinel) + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + + if (instanceGetterFieldValue != null) + _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, + }; + + batch.update(reference, json); + } + + @override + bool operator ==(Object other) { + return other is SubClassDocumentReference && + other.runtimeType == runtimeType && + other.parent == parent && + other.id == id; + } + + @override + int get hashCode => Object.hash(runtimeType, parent, id); +} + +abstract class SubClassQuery + implements QueryReference { + @override + SubClassQuery limit(int limit); + + @override + SubClassQuery limitToLast(int limit); + + /// Perform a where query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of where queries: + /// + /// **AVOID**: + /// ```dart + /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.whereTitle(isEqualTo: 'title'); + /// ``` + SubClassQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo, + Object? isNotEqualTo, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SubClassQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + SubClassQuery whereInstanceGetter({ + int? isEqualTo, + int? isNotEqualTo, + int? isLessThan, + int? isLessThanOrEqualTo, + int? isGreaterThan, + int? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }); + + /// Perform an order query based on a [FieldPath]. + /// + /// This method is considered unsafe as it does check that the field path + /// maps to a valid property or that parameters such as [isEqualTo] receive + /// a value of the correct type. + /// + /// If possible, instead use the more explicit variant of order queries: + /// + /// **AVOID**: + /// ```dart + /// collection.orderByFieldPath( + /// FieldPath.fromString('title'), + /// startAt: 'title', + /// ); + /// ``` + /// + /// **PREFER**: + /// ```dart + /// collection.orderByTitle(startAt: 'title'); + /// ``` + SubClassQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object startAt, + Object startAfter, + Object endAt, + Object endBefore, + SubClassDocumentSnapshot? startAtDocument, + SubClassDocumentSnapshot? endAtDocument, + SubClassDocumentSnapshot? endBeforeDocument, + SubClassDocumentSnapshot? startAfterDocument, + }); + + SubClassQuery orderByDocumentId({ + bool descending = false, + String startAt, + String startAfter, + String endAt, + String endBefore, + SubClassDocumentSnapshot? startAtDocument, + SubClassDocumentSnapshot? endAtDocument, + SubClassDocumentSnapshot? endBeforeDocument, + SubClassDocumentSnapshot? startAfterDocument, + }); + + SubClassQuery orderByInstanceGetter({ + bool descending = false, + int startAt, + int startAfter, + int endAt, + int endBefore, + SubClassDocumentSnapshot? startAtDocument, + SubClassDocumentSnapshot? endAtDocument, + SubClassDocumentSnapshot? endBeforeDocument, + SubClassDocumentSnapshot? startAfterDocument, + }); +} + +class _$SubClassQuery extends QueryReference + implements SubClassQuery { + _$SubClassQuery( + this._collection, { + required Query $referenceWithoutCursor, + $QueryCursor $queryCursor = const $QueryCursor(), + }) : super( + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); + + final CollectionReference _collection; + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(SubClassQuerySnapshot._fromQuerySnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference + .get(options) + .then(SubClassQuerySnapshot._fromQuerySnapshot); + } + + @override + SubClassQuery limit(int limit) { + return _$SubClassQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), + $queryCursor: $queryCursor, + ); + } + + @override + SubClassQuery limitToLast(int limit) { + return _$SubClassQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), + $queryCursor: $queryCursor, + ); + } + + @override + SubClassQuery whereFieldPath( + Object fieldPath, { + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + Object? arrayContains, + List? arrayContainsAny, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SubClassQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + fieldPath, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + arrayContains: arrayContains, + arrayContainsAny: arrayContainsAny, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SubClassQuery whereDocumentId({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SubClassQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + FieldPath.documentId, + isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, + isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + whereIn: whereIn, + whereNotIn: whereNotIn, + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SubClassQuery whereInstanceGetter({ + Object? isEqualTo = _sentinel, + Object? isNotEqualTo = _sentinel, + Object? isLessThan, + Object? isLessThanOrEqualTo, + Object? isGreaterThan, + Object? isGreaterThanOrEqualTo, + List? whereIn, + List? whereNotIn, + bool? isNull, + }) { + return _$SubClassQuery( + _collection, + $referenceWithoutCursor: $referenceWithoutCursor.where( + _$SubClassFieldMap['instanceGetter']!, + isEqualTo: isEqualTo != _sentinel + ? _$SubClassPerFieldToJson.instanceGetter(isEqualTo as int) + : null, + isNotEqualTo: isNotEqualTo != _sentinel + ? _$SubClassPerFieldToJson.instanceGetter(isNotEqualTo as int) + : null, + isLessThan: isLessThan != null + ? _$SubClassPerFieldToJson.instanceGetter(isLessThan as int) + : null, + isLessThanOrEqualTo: isLessThanOrEqualTo != null + ? _$SubClassPerFieldToJson.instanceGetter( + isLessThanOrEqualTo as int, + ) + : null, + isGreaterThan: isGreaterThan != null + ? _$SubClassPerFieldToJson.instanceGetter(isGreaterThan as int) + : null, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null + ? _$SubClassPerFieldToJson.instanceGetter( + isGreaterThanOrEqualTo as int, + ) + : null, + whereIn: whereIn?.map( + (e) => _$SubClassPerFieldToJson.instanceGetter(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$SubClassPerFieldToJson.instanceGetter(e), + ), + isNull: + isNull ?? + (isEqualTo == null ? false : null) ?? + (isNotEqualTo == null ? true : null), + ), + $queryCursor: $queryCursor, + ); + } + + @override + SubClassQuery orderByFieldPath( + Object fieldPath, { + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SubClassDocumentSnapshot? startAtDocument, + SubClassDocumentSnapshot? endAtDocument, + SubClassDocumentSnapshot? endBeforeDocument, + SubClassDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SubClassQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SubClassQuery orderByDocumentId({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SubClassDocumentSnapshot? startAtDocument, + SubClassDocumentSnapshot? endAtDocument, + SubClassDocumentSnapshot? endBeforeDocument, + SubClassDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [...queryCursor.startAt, startAt], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [...queryCursor.startAfter, startAfter], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [...queryCursor.endAt, endAt], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [...queryCursor.endBefore, endBefore], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SubClassQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + SubClassQuery orderByInstanceGetter({ + bool descending = false, + Object? startAt = _sentinel, + Object? startAfter = _sentinel, + Object? endAt = _sentinel, + Object? endBefore = _sentinel, + SubClassDocumentSnapshot? startAtDocument, + SubClassDocumentSnapshot? endAtDocument, + SubClassDocumentSnapshot? endBeforeDocument, + SubClassDocumentSnapshot? startAfterDocument, + }) { + final query = $referenceWithoutCursor.orderBy( + _$SubClassFieldMap['instanceGetter']!, + descending: descending, + ); + var queryCursor = $queryCursor; + + if (startAtDocument != null) { + queryCursor = queryCursor.copyWith( + startAt: const [], + startAtDocumentSnapshot: startAtDocument.snapshot, + ); + } + if (startAfterDocument != null) { + queryCursor = queryCursor.copyWith( + startAfter: const [], + startAfterDocumentSnapshot: startAfterDocument.snapshot, + ); + } + if (endAtDocument != null) { + queryCursor = queryCursor.copyWith( + endAt: const [], + endAtDocumentSnapshot: endAtDocument.snapshot, + ); + } + if (endBeforeDocument != null) { + queryCursor = queryCursor.copyWith( + endBefore: const [], + endBeforeDocumentSnapshot: endBeforeDocument.snapshot, + ); + } + + if (startAt != _sentinel) { + queryCursor = queryCursor.copyWith( + startAt: [ + ...queryCursor.startAt, + _$SubClassPerFieldToJson.instanceGetter(startAt as int), + ], + startAtDocumentSnapshot: null, + ); + } + if (startAfter != _sentinel) { + queryCursor = queryCursor.copyWith( + startAfter: [ + ...queryCursor.startAfter, + _$SubClassPerFieldToJson.instanceGetter(startAfter as int), + ], + startAfterDocumentSnapshot: null, + ); + } + if (endAt != _sentinel) { + queryCursor = queryCursor.copyWith( + endAt: [ + ...queryCursor.endAt, + _$SubClassPerFieldToJson.instanceGetter(endAt as int), + ], + endAtDocumentSnapshot: null, + ); + } + if (endBefore != _sentinel) { + queryCursor = queryCursor.copyWith( + endBefore: [ + ...queryCursor.endBefore, + _$SubClassPerFieldToJson.instanceGetter(endBefore as int), + ], + endBeforeDocumentSnapshot: null, + ); + } + + return _$SubClassQuery( + _collection, + $referenceWithoutCursor: query, + $queryCursor: queryCursor, + ); + } + + @override + bool operator ==(Object other) { + return other is _$SubClassQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class SubClassDocumentSnapshot extends FirestoreDocumentSnapshot { + SubClassDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final DocumentSnapshot snapshot; + + @override + SubClassDocumentReference get reference { + return SubClassDocumentReference(snapshot.reference); + } + + @override + final SubClass? data; +} + +class SubClassQuerySnapshot + extends FirestoreQuerySnapshot { + SubClassQuerySnapshot._(this.snapshot, this.docs, this.docChanges); + + factory SubClassQuerySnapshot._fromQuerySnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map(SubClassQueryDocumentSnapshot._).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return _decodeDocumentChange(change, SubClassDocumentSnapshot._); + }).toList(); + + return SubClassQuerySnapshot._(snapshot, docs, docChanges); + } + + static FirestoreDocumentChange + _decodeDocumentChange( + DocumentChange docChange, + SubClassDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, + ) { + return FirestoreDocumentChange( + type: docChange.type, + oldIndex: docChange.oldIndex, + newIndex: docChange.newIndex, + doc: decodeDoc(docChange.doc), + ); + } + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class SubClassQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements SubClassDocumentSnapshot { + SubClassQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); + + @override + final QueryDocumentSnapshot snapshot; + + @override + final SubClass data; + + @override + SubClassDocumentReference get reference { + return SubClassDocumentReference(snapshot.reference); + } +} + +// ************************************************************************** +// ValidatorGenerator +// ************************************************************************** + +void _$assertMinValidation(MinValidation instance) { + const Min(0).validate(instance.intNbr, 'intNbr'); + const Max(42).validate(instance.intNbr, 'intNbr'); + const Min(10).validate(instance.doubleNbr, 'doubleNbr'); + const Min(-10).validate(instance.numNbr, 'numNbr'); +} 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 e4b949b..ef172f2 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 @@ -2,15524 +2,12 @@ part of 'simple.dart'; -// ************************************************************************** -// CollectionGenerator -// ************************************************************************** - -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, require_trailing_commas, prefer_single_quotes, prefer_double_quotes, use_super_parameters, duplicate_ignore -// ignore_for_file: type=lint -// ignore_for_file: invalid_use_of_internal_member - -class _Sentinel { - const _Sentinel(); -} - -const _sentinel = _Sentinel(); - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class IgnoredGetterCollectionReference - implements - IgnoredGetterQuery, - FirestoreCollectionReference { - factory IgnoredGetterCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$IgnoredGetterCollectionReference; - - static IgnoredGetter fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$IgnoredGetterFromJson(snapshot.data()!); - } - - static Map toFirestore( - IgnoredGetter value, - SetOptions? options, - ) { - return _$IgnoredGetterToJson(value); - } - - @override - CollectionReference get reference; - - @override - IgnoredGetterDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(IgnoredGetter value); -} - -class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery - implements IgnoredGetterCollectionReference { - factory _$IgnoredGetterCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$IgnoredGetterCollectionReference._( - firestore.collection('firestore-example-app/test/getter').withConverter( - fromFirestore: IgnoredGetterCollectionReference.fromFirestore, - toFirestore: IgnoredGetterCollectionReference.toFirestore, - ), - ); - } - - _$IgnoredGetterCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - IgnoredGetterDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return IgnoredGetterDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(IgnoredGetter value) { - return reference - .add(value) - .then((ref) => IgnoredGetterDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$IgnoredGetterCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class IgnoredGetterDocumentReference - extends FirestoreDocumentReference { - factory IgnoredGetterDocumentReference( - DocumentReference reference) = - _$IgnoredGetterDocumentReference; - - DocumentReference get reference; - - /// A reference to the [IgnoredGetterCollectionReference] containing this document. - IgnoredGetterCollectionReference get parent { - return _$IgnoredGetterCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - IgnoredGetter model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - IgnoredGetter model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - IgnoredGetter model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - IgnoredGetter, - IgnoredGetterDocumentSnapshot> implements IgnoredGetterDocumentReference { - _$IgnoredGetterDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [IgnoredGetterCollectionReference] containing this document. - IgnoredGetterCollectionReference get parent { - return _$IgnoredGetterCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(IgnoredGetterDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(IgnoredGetterDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(IgnoredGetterDocumentSnapshot._); - } - - Future set( - IgnoredGetter model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ..._$IgnoredGetterToJson(model), - if (valueFieldValue != null) - _$IgnoredGetterFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - IgnoredGetter model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ..._$IgnoredGetterToJson(model), - if (valueFieldValue != null) - _$IgnoredGetterFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - IgnoredGetter model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ..._$IgnoredGetterToJson(model), - if (valueFieldValue != null) - _$IgnoredGetterFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class IgnoredGetterQuery - implements QueryReference { - @override - IgnoredGetterQuery limit(int limit); - - @override - IgnoredGetterQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - IgnoredGetterQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - IgnoredGetterQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - IgnoredGetterQuery whereValue({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - IgnoredGetterQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - IgnoredGetterDocumentSnapshot? startAtDocument, - IgnoredGetterDocumentSnapshot? endAtDocument, - IgnoredGetterDocumentSnapshot? endBeforeDocument, - IgnoredGetterDocumentSnapshot? startAfterDocument, - }); - - IgnoredGetterQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - IgnoredGetterDocumentSnapshot? startAtDocument, - IgnoredGetterDocumentSnapshot? endAtDocument, - IgnoredGetterDocumentSnapshot? endBeforeDocument, - IgnoredGetterDocumentSnapshot? startAfterDocument, - }); - - IgnoredGetterQuery orderByValue({ - bool descending = false, - int startAt, - int startAfter, - int endAt, - int endBefore, - IgnoredGetterDocumentSnapshot? startAtDocument, - IgnoredGetterDocumentSnapshot? endAtDocument, - IgnoredGetterDocumentSnapshot? endBeforeDocument, - IgnoredGetterDocumentSnapshot? startAfterDocument, - }); -} - -class _$IgnoredGetterQuery - extends QueryReference - implements IgnoredGetterQuery { - _$IgnoredGetterQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(IgnoredGetterQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(IgnoredGetterQuerySnapshot._fromQuerySnapshot); - } - - @override - IgnoredGetterQuery limit(int limit) { - return _$IgnoredGetterQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - IgnoredGetterQuery limitToLast(int limit) { - return _$IgnoredGetterQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - IgnoredGetterQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$IgnoredGetterQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - IgnoredGetterQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$IgnoredGetterQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - IgnoredGetterQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$IgnoredGetterQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$IgnoredGetterFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$IgnoredGetterPerFieldToJson.value(isEqualTo as int) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$IgnoredGetterPerFieldToJson.value(isNotEqualTo as int) - : null, - isLessThan: isLessThan != null - ? _$IgnoredGetterPerFieldToJson.value(isLessThan as int) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$IgnoredGetterPerFieldToJson.value(isLessThanOrEqualTo as int) - : null, - isGreaterThan: isGreaterThan != null - ? _$IgnoredGetterPerFieldToJson.value(isGreaterThan as int) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$IgnoredGetterPerFieldToJson.value(isGreaterThanOrEqualTo as int) - : null, - whereIn: whereIn?.map((e) => _$IgnoredGetterPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$IgnoredGetterPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - IgnoredGetterQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - IgnoredGetterDocumentSnapshot? startAtDocument, - IgnoredGetterDocumentSnapshot? endAtDocument, - IgnoredGetterDocumentSnapshot? endBeforeDocument, - IgnoredGetterDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$IgnoredGetterQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - IgnoredGetterQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - IgnoredGetterDocumentSnapshot? startAtDocument, - IgnoredGetterDocumentSnapshot? endAtDocument, - IgnoredGetterDocumentSnapshot? endBeforeDocument, - IgnoredGetterDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$IgnoredGetterQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - IgnoredGetterQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - IgnoredGetterDocumentSnapshot? startAtDocument, - IgnoredGetterDocumentSnapshot? endAtDocument, - IgnoredGetterDocumentSnapshot? endBeforeDocument, - IgnoredGetterDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$IgnoredGetterFieldMap['value']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$IgnoredGetterQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$IgnoredGetterQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class IgnoredGetterDocumentSnapshot - extends FirestoreDocumentSnapshot { - IgnoredGetterDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - IgnoredGetterDocumentReference get reference { - return IgnoredGetterDocumentReference( - snapshot.reference, - ); - } - - @override - final IgnoredGetter? data; -} - -class IgnoredGetterQuerySnapshot extends FirestoreQuerySnapshot { - IgnoredGetterQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory IgnoredGetterQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(IgnoredGetterQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - IgnoredGetterDocumentSnapshot._, - ); - }).toList(); - - return IgnoredGetterQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - IgnoredGetterDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class IgnoredGetterQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements IgnoredGetterDocumentSnapshot { - IgnoredGetterQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final IgnoredGetter data; - - @override - IgnoredGetterDocumentReference get reference { - return IgnoredGetterDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class ModelCollectionReference - implements - ModelQuery, - FirestoreCollectionReference { - factory ModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ModelCollectionReference; - - static Model fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$ModelFromJson(snapshot.data()!); - } - - static Map toFirestore( - Model value, - SetOptions? options, - ) { - return _$ModelToJson(value); - } - - @override - CollectionReference get reference; - - @override - ModelDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Model value); -} - -class _$ModelCollectionReference extends _$ModelQuery - implements ModelCollectionReference { - factory _$ModelCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$ModelCollectionReference._( - firestore.collection('root').withConverter( - fromFirestore: ModelCollectionReference.fromFirestore, - toFirestore: ModelCollectionReference.toFirestore, - ), - ); - } - - _$ModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - ModelDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return ModelDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Model value) { - return reference.add(value).then((ref) => ModelDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$ModelCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class ModelDocumentReference - extends FirestoreDocumentReference { - factory ModelDocumentReference(DocumentReference reference) = - _$ModelDocumentReference; - - DocumentReference get reference; - - /// A reference to the [ModelCollectionReference] containing this document. - ModelCollectionReference get parent { - return _$ModelCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Model model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Model model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Model model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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 - extends FirestoreDocumentReference - implements ModelDocumentReference { - _$ModelDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [ModelCollectionReference] containing this document. - ModelCollectionReference get parent { - return _$ModelCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(ModelDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(ModelDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(ModelDocumentSnapshot._); - } - - Future set( - Model model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ..._$ModelToJson(model), - if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Model model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ..._$ModelToJson(model), - if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Model model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ..._$ModelToJson(model), - if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class ModelQuery implements QueryReference { - @override - ModelQuery limit(int limit); - - @override - ModelQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - ModelQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ModelQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ModelQuery whereValue({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - ModelQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - ModelDocumentSnapshot? startAtDocument, - ModelDocumentSnapshot? endAtDocument, - ModelDocumentSnapshot? endBeforeDocument, - ModelDocumentSnapshot? startAfterDocument, - }); - - ModelQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - ModelDocumentSnapshot? startAtDocument, - ModelDocumentSnapshot? endAtDocument, - ModelDocumentSnapshot? endBeforeDocument, - ModelDocumentSnapshot? startAfterDocument, - }); - - ModelQuery orderByValue({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - ModelDocumentSnapshot? startAtDocument, - ModelDocumentSnapshot? endAtDocument, - ModelDocumentSnapshot? endBeforeDocument, - ModelDocumentSnapshot? startAfterDocument, - }); -} - -class _$ModelQuery extends QueryReference - implements ModelQuery { - _$ModelQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(ModelQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(ModelQuerySnapshot._fromQuerySnapshot); - } - - @override - ModelQuery limit(int limit) { - return _$ModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ModelQuery limitToLast(int limit) { - return _$ModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ModelQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ModelQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ModelQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$ModelFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$ModelPerFieldToJson.value(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$ModelPerFieldToJson.value(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$ModelPerFieldToJson.value(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$ModelPerFieldToJson.value(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$ModelPerFieldToJson.value(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$ModelPerFieldToJson.value(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$ModelPerFieldToJson.value(e)), - whereNotIn: whereNotIn?.map((e) => _$ModelPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ModelQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ModelDocumentSnapshot? startAtDocument, - ModelDocumentSnapshot? endAtDocument, - ModelDocumentSnapshot? endBeforeDocument, - ModelDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ModelQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ModelQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ModelDocumentSnapshot? startAtDocument, - ModelDocumentSnapshot? endAtDocument, - ModelDocumentSnapshot? endBeforeDocument, - ModelDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ModelQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ModelQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ModelDocumentSnapshot? startAtDocument, - ModelDocumentSnapshot? endAtDocument, - ModelDocumentSnapshot? endBeforeDocument, - ModelDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$ModelFieldMap['value']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ModelQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$ModelQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class ModelDocumentSnapshot extends FirestoreDocumentSnapshot { - ModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - ModelDocumentReference get reference { - return ModelDocumentReference( - snapshot.reference, - ); - } - - @override - final Model? data; -} - -class ModelQuerySnapshot - extends FirestoreQuerySnapshot { - ModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory ModelQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(ModelQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ModelDocumentSnapshot._, - ); - }).toList(); - - return ModelQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - ModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class ModelQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements ModelDocumentSnapshot { - ModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Model data; - - @override - ModelDocumentReference get reference { - return ModelDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class NestedCollectionReference - implements - NestedQuery, - FirestoreCollectionReference { - factory NestedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$NestedCollectionReference; - - static Nested fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return Nested.fromJson(snapshot.data()!); - } - - static Map toFirestore( - Nested value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - NestedDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Nested value); -} - -class _$NestedCollectionReference extends _$NestedQuery - implements NestedCollectionReference { - factory _$NestedCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$NestedCollectionReference._( - firestore.collection('nested').withConverter( - fromFirestore: NestedCollectionReference.fromFirestore, - toFirestore: NestedCollectionReference.toFirestore, - ), - ); - } - - _$NestedCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - NestedDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return NestedDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Nested value) { - return reference.add(value).then((ref) => NestedDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$NestedCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class NestedDocumentReference - extends FirestoreDocumentReference { - factory NestedDocumentReference(DocumentReference reference) = - _$NestedDocumentReference; - - DocumentReference get reference; - - /// A reference to the [NestedCollectionReference] containing this document. - NestedCollectionReference get parent { - return _$NestedCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Nested model, { - SetOptions? options, - FieldValue valueFieldValue, - FieldValue simpleFieldValue, - FieldValue valueListFieldValue, - FieldValue boolListFieldValue, - FieldValue stringListFieldValue, - FieldValue numListFieldValue, - FieldValue objectListFieldValue, - FieldValue dynamicListFieldValue, - FieldValue boolSetFieldValue, - FieldValue enumValueFieldValue, - FieldValue nullableEnumValueFieldValue, - FieldValue enumListFieldValue, - FieldValue nullableEnumListFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Nested model, { - SetOptions? options, - FieldValue valueFieldValue, - FieldValue simpleFieldValue, - FieldValue valueListFieldValue, - FieldValue boolListFieldValue, - FieldValue stringListFieldValue, - FieldValue numListFieldValue, - FieldValue objectListFieldValue, - FieldValue dynamicListFieldValue, - FieldValue boolSetFieldValue, - FieldValue enumValueFieldValue, - FieldValue nullableEnumValueFieldValue, - FieldValue enumListFieldValue, - FieldValue nullableEnumListFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Nested model, { - SetOptions? options, - FieldValue valueFieldValue, - FieldValue simpleFieldValue, - FieldValue valueListFieldValue, - FieldValue boolListFieldValue, - FieldValue stringListFieldValue, - FieldValue numListFieldValue, - FieldValue objectListFieldValue, - FieldValue dynamicListFieldValue, - FieldValue boolSetFieldValue, - FieldValue enumValueFieldValue, - FieldValue nullableEnumValueFieldValue, - FieldValue enumListFieldValue, - FieldValue nullableEnumListFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - 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, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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, - }); - - /// 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 - extends FirestoreDocumentReference - implements NestedDocumentReference { - _$NestedDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [NestedCollectionReference] containing this document. - NestedCollectionReference get parent { - return _$NestedCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(NestedDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(NestedDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(NestedDocumentSnapshot._); - } - - Future set( - Nested model, { - SetOptions? options, - FieldValue? valueFieldValue, - FieldValue? simpleFieldValue, - FieldValue? valueListFieldValue, - FieldValue? boolListFieldValue, - FieldValue? stringListFieldValue, - FieldValue? numListFieldValue, - FieldValue? objectListFieldValue, - FieldValue? dynamicListFieldValue, - FieldValue? boolSetFieldValue, - FieldValue? enumValueFieldValue, - FieldValue? nullableEnumValueFieldValue, - FieldValue? enumListFieldValue, - FieldValue? nullableEnumListFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, - if (simpleFieldValue != null) - _$NestedFieldMap['simple']!: simpleFieldValue, - if (valueListFieldValue != null) - _$NestedFieldMap['valueList']!: valueListFieldValue, - if (boolListFieldValue != null) - _$NestedFieldMap['boolList']!: boolListFieldValue, - if (stringListFieldValue != null) - _$NestedFieldMap['stringList']!: stringListFieldValue, - if (numListFieldValue != null) - _$NestedFieldMap['numList']!: numListFieldValue, - if (objectListFieldValue != null) - _$NestedFieldMap['objectList']!: objectListFieldValue, - if (dynamicListFieldValue != null) - _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, - if (boolSetFieldValue != null) - _$NestedFieldMap['boolSet']!: boolSetFieldValue, - if (enumValueFieldValue != null) - _$NestedFieldMap['enumValue']!: enumValueFieldValue, - if (nullableEnumValueFieldValue != null) - _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, - if (enumListFieldValue != null) - _$NestedFieldMap['enumList']!: enumListFieldValue, - if (nullableEnumListFieldValue != null) - _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Nested model, { - SetOptions? options, - FieldValue? valueFieldValue, - FieldValue? simpleFieldValue, - FieldValue? valueListFieldValue, - FieldValue? boolListFieldValue, - FieldValue? stringListFieldValue, - FieldValue? numListFieldValue, - FieldValue? objectListFieldValue, - FieldValue? dynamicListFieldValue, - FieldValue? boolSetFieldValue, - FieldValue? enumValueFieldValue, - FieldValue? nullableEnumValueFieldValue, - FieldValue? enumListFieldValue, - FieldValue? nullableEnumListFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, - if (simpleFieldValue != null) - _$NestedFieldMap['simple']!: simpleFieldValue, - if (valueListFieldValue != null) - _$NestedFieldMap['valueList']!: valueListFieldValue, - if (boolListFieldValue != null) - _$NestedFieldMap['boolList']!: boolListFieldValue, - if (stringListFieldValue != null) - _$NestedFieldMap['stringList']!: stringListFieldValue, - if (numListFieldValue != null) - _$NestedFieldMap['numList']!: numListFieldValue, - if (objectListFieldValue != null) - _$NestedFieldMap['objectList']!: objectListFieldValue, - if (dynamicListFieldValue != null) - _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, - if (boolSetFieldValue != null) - _$NestedFieldMap['boolSet']!: boolSetFieldValue, - if (enumValueFieldValue != null) - _$NestedFieldMap['enumValue']!: enumValueFieldValue, - if (nullableEnumValueFieldValue != null) - _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, - if (enumListFieldValue != null) - _$NestedFieldMap['enumList']!: enumListFieldValue, - if (nullableEnumListFieldValue != null) - _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Nested model, { - SetOptions? options, - FieldValue? valueFieldValue, - FieldValue? simpleFieldValue, - FieldValue? valueListFieldValue, - FieldValue? boolListFieldValue, - FieldValue? stringListFieldValue, - FieldValue? numListFieldValue, - FieldValue? objectListFieldValue, - FieldValue? dynamicListFieldValue, - FieldValue? boolSetFieldValue, - FieldValue? enumValueFieldValue, - FieldValue? nullableEnumValueFieldValue, - FieldValue? enumListFieldValue, - FieldValue? nullableEnumListFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, - if (simpleFieldValue != null) - _$NestedFieldMap['simple']!: simpleFieldValue, - if (valueListFieldValue != null) - _$NestedFieldMap['valueList']!: valueListFieldValue, - if (boolListFieldValue != null) - _$NestedFieldMap['boolList']!: boolListFieldValue, - if (stringListFieldValue != null) - _$NestedFieldMap['stringList']!: stringListFieldValue, - if (numListFieldValue != null) - _$NestedFieldMap['numList']!: numListFieldValue, - if (objectListFieldValue != null) - _$NestedFieldMap['objectList']!: objectListFieldValue, - if (dynamicListFieldValue != null) - _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, - if (boolSetFieldValue != null) - _$NestedFieldMap['boolSet']!: boolSetFieldValue, - if (enumValueFieldValue != null) - _$NestedFieldMap['enumValue']!: enumValueFieldValue, - if (nullableEnumValueFieldValue != null) - _$NestedFieldMap['nullableEnumValue']!: nullableEnumValueFieldValue, - if (enumListFieldValue != null) - _$NestedFieldMap['enumList']!: enumListFieldValue, - if (nullableEnumListFieldValue != null) - _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - 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, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class NestedQuery - implements QueryReference { - @override - NestedQuery limit(int limit); - - @override - NestedQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - NestedQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - NestedQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - NestedQuery whereValue({ - Nested? isEqualTo, - Nested? isNotEqualTo, - Nested? isLessThan, - Nested? isLessThanOrEqualTo, - Nested? isGreaterThan, - Nested? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - NestedQuery whereSimple({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - NestedQuery whereValueList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - Nested? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - NestedQuery whereBoolList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - bool? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - NestedQuery whereStringList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - String? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - NestedQuery whereNumList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - num? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - NestedQuery whereObjectList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - NestedQuery whereDynamicList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - dynamic arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - NestedQuery whereBoolSet({ - Set? isEqualTo, - Set? isNotEqualTo, - Set? isLessThan, - Set? isLessThanOrEqualTo, - Set? isGreaterThan, - Set? isGreaterThanOrEqualTo, - bool? arrayContains, - Set? arrayContainsAny, - bool? isNull, - }); - - NestedQuery whereEnumValue({ - TestEnum? isEqualTo, - TestEnum? isNotEqualTo, - TestEnum? isLessThan, - TestEnum? isLessThanOrEqualTo, - TestEnum? isGreaterThan, - TestEnum? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - NestedQuery whereNullableEnumValue({ - TestEnum? isEqualTo, - TestEnum? isNotEqualTo, - TestEnum? isLessThan, - TestEnum? isLessThanOrEqualTo, - TestEnum? isGreaterThan, - TestEnum? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - NestedQuery whereEnumList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - TestEnum? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - NestedQuery whereNullableEnumList({ - List? isEqualTo, - List? isNotEqualTo, - List? isLessThan, - List? isLessThanOrEqualTo, - List? isGreaterThan, - List? isGreaterThanOrEqualTo, - TestEnum? arrayContains, - List? arrayContainsAny, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - NestedQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByValue({ - bool descending = false, - Nested? startAt, - Nested? startAfter, - Nested? endAt, - Nested? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderBySimple({ - bool descending = false, - int? startAt, - int? startAfter, - int? endAt, - int? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByValueList({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByBoolList({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByStringList({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByNumList({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByObjectList({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByDynamicList({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByBoolSet({ - bool descending = false, - Set? startAt, - Set? startAfter, - Set? endAt, - Set? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByEnumValue({ - bool descending = false, - TestEnum startAt, - TestEnum startAfter, - TestEnum endAt, - TestEnum endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByNullableEnumValue({ - bool descending = false, - TestEnum? startAt, - TestEnum? startAfter, - TestEnum? endAt, - TestEnum? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByEnumList({ - bool descending = false, - List startAt, - List startAfter, - List endAt, - List endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); - - NestedQuery orderByNullableEnumList({ - bool descending = false, - List? startAt, - List? startAfter, - List? endAt, - List? endBefore, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }); -} - -class _$NestedQuery extends QueryReference - implements NestedQuery { - _$NestedQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(NestedQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(NestedQuerySnapshot._fromQuerySnapshot); - } - - @override - NestedQuery limit(int limit) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery limitToLast(int limit) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.value(isEqualTo as Nested?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.value(isNotEqualTo as Nested?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.value(isLessThan as Nested?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson.value(isLessThanOrEqualTo as Nested?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.value(isGreaterThan as Nested?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson.value(isGreaterThanOrEqualTo as Nested?) - : null, - whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.value(e)), - whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereSimple({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['simple']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.simple(isEqualTo as int?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.simple(isNotEqualTo as int?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.simple(isLessThan as int?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson.simple(isLessThanOrEqualTo as int?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.simple(isGreaterThan as int?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson.simple(isGreaterThanOrEqualTo as int?) - : null, - whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.simple(e)), - whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.simple(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereValueList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['valueList']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.valueList(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.valueList(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.valueList(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .valueList(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.valueList(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .valueList(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson.valueList([arrayContains as Nested]) - as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.valueList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereBoolList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['boolList']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.boolList(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.boolList(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.boolList(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolList(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.boolList(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolList(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson.boolList([arrayContains as bool]) - as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.boolList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereStringList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['stringList']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.stringList(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.stringList(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.stringList(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .stringList(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.stringList(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .stringList(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson.stringList([arrayContains as String]) - as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.stringList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereNumList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['numList']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.numList(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.numList(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.numList(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson.numList(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.numList(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .numList(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson.numList([arrayContains as num]) as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.numList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereObjectList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['objectList']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.objectList(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.objectList(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.objectList(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .objectList(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.objectList(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .objectList(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson.objectList([arrayContains]) as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.objectList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereDynamicList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['dynamicList']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.dynamicList(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.dynamicList(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.dynamicList(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .dynamicList(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .dynamicList(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .dynamicList(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson.dynamicList([arrayContains as dynamic]) - as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.dynamicList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereBoolSet({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - Set? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['boolSet']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.boolSet(isEqualTo as Set?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.boolSet(isNotEqualTo as Set?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.boolSet(isLessThan as Set?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson.boolSet(isLessThanOrEqualTo as Set?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.boolSet(isGreaterThan as Set?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolSet(isGreaterThanOrEqualTo as Set?) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson.boolSet({arrayContains as bool}) - as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.boolSet(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereEnumValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['enumValue']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.enumValue(isEqualTo as TestEnum) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.enumValue(isNotEqualTo as TestEnum) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.enumValue(isLessThan as TestEnum) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson.enumValue(isLessThanOrEqualTo as TestEnum) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.enumValue(isGreaterThan as TestEnum) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumValue(isGreaterThanOrEqualTo as TestEnum) - : null, - whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.enumValue(e)), - whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.enumValue(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereNullableEnumValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['nullableEnumValue']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.nullableEnumValue(isEqualTo as TestEnum?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumValue(isNotEqualTo as TestEnum?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.nullableEnumValue(isLessThan as TestEnum?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumValue(isLessThanOrEqualTo as TestEnum?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .nullableEnumValue(isGreaterThan as TestEnum?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumValue(isGreaterThanOrEqualTo as TestEnum?) - : null, - whereIn: - whereIn?.map((e) => _$NestedPerFieldToJson.nullableEnumValue(e)), - whereNotIn: - whereNotIn?.map((e) => _$NestedPerFieldToJson.nullableEnumValue(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereEnumList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['enumList']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson.enumList(isEqualTo as List) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson.enumList(isNotEqualTo as List) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson.enumList(isLessThan as List) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumList(isLessThanOrEqualTo as List) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson.enumList(isGreaterThan as List) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumList(isGreaterThanOrEqualTo as List) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson.enumList([arrayContains as TestEnum]) - as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.enumList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery whereNullableEnumList({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - bool? isNull, - }) { - return _$NestedQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$NestedFieldMap['nullableEnumList']!, - isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumList(isEqualTo as List?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumList(isNotEqualTo as List?) - : null, - isLessThan: isLessThan != null - ? _$NestedPerFieldToJson - .nullableEnumList(isLessThan as List?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumList(isLessThanOrEqualTo as List?) - : null, - isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .nullableEnumList(isGreaterThan as List?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumList(isGreaterThanOrEqualTo as List?) - : null, - arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson - .nullableEnumList([arrayContains as TestEnum]) as List?)! - .single - : null, - arrayContainsAny: arrayContainsAny != null - ? _$NestedPerFieldToJson.nullableEnumList(arrayContainsAny) - as Iterable? - : null, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - NestedQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['value']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderBySimple({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['simple']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByValueList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['valueList']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByBoolList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['boolList']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByStringList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['stringList']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByNumList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['numList']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByObjectList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['objectList']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByDynamicList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['dynamicList']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByBoolSet({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['boolSet']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByEnumValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['enumValue']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByNullableEnumValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy( - _$NestedFieldMap['nullableEnumValue']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByEnumList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['enumList']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - NestedQuery orderByNullableEnumList({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - NestedDocumentSnapshot? startAtDocument, - NestedDocumentSnapshot? endAtDocument, - NestedDocumentSnapshot? endBeforeDocument, - NestedDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['nullableEnumList']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$NestedQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$NestedQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class NestedDocumentSnapshot extends FirestoreDocumentSnapshot { - NestedDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - NestedDocumentReference get reference { - return NestedDocumentReference( - snapshot.reference, - ); - } - - @override - final Nested? data; -} - -class NestedQuerySnapshot - extends FirestoreQuerySnapshot { - NestedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory NestedQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(NestedQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - NestedDocumentSnapshot._, - ); - }).toList(); - - return NestedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - NestedDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class NestedQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements NestedDocumentSnapshot { - NestedQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Nested data; - - @override - NestedDocumentReference get reference { - return NestedDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class EmptyModelCollectionReference - implements - EmptyModelQuery, - FirestoreCollectionReference { - factory EmptyModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EmptyModelCollectionReference; - - static EmptyModel fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return EmptyModel.fromJson(snapshot.data()!); - } - - static Map toFirestore( - EmptyModel value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - EmptyModelDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(EmptyModel value); -} - -class _$EmptyModelCollectionReference extends _$EmptyModelQuery - implements EmptyModelCollectionReference { - factory _$EmptyModelCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$EmptyModelCollectionReference._( - firestore.collection('config').withConverter( - fromFirestore: EmptyModelCollectionReference.fromFirestore, - toFirestore: EmptyModelCollectionReference.toFirestore, - ), - ); - } - - _$EmptyModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - EmptyModelDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return EmptyModelDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(EmptyModel value) { - return reference.add(value).then((ref) => EmptyModelDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$EmptyModelCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class EmptyModelDocumentReference - extends FirestoreDocumentReference { - factory EmptyModelDocumentReference(DocumentReference reference) = - _$EmptyModelDocumentReference; - - DocumentReference get reference; - - /// A reference to the [EmptyModelCollectionReference] containing this document. - EmptyModelCollectionReference get parent { - return _$EmptyModelCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); -} - -class _$EmptyModelDocumentReference - extends FirestoreDocumentReference - implements EmptyModelDocumentReference { - _$EmptyModelDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [EmptyModelCollectionReference] containing this document. - EmptyModelCollectionReference get parent { - return _$EmptyModelCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(EmptyModelDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(EmptyModelDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(EmptyModelDocumentSnapshot._); - } - - @override - bool operator ==(Object other) { - return other is EmptyModelDocumentReference && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class EmptyModelQuery - implements QueryReference { - @override - EmptyModelQuery limit(int limit); - - @override - EmptyModelQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - EmptyModelQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - EmptyModelQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - EmptyModelQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - EmptyModelDocumentSnapshot? startAtDocument, - EmptyModelDocumentSnapshot? endAtDocument, - EmptyModelDocumentSnapshot? endBeforeDocument, - EmptyModelDocumentSnapshot? startAfterDocument, - }); - - EmptyModelQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - EmptyModelDocumentSnapshot? startAtDocument, - EmptyModelDocumentSnapshot? endAtDocument, - EmptyModelDocumentSnapshot? endBeforeDocument, - EmptyModelDocumentSnapshot? startAfterDocument, - }); -} - -class _$EmptyModelQuery - extends QueryReference - implements EmptyModelQuery { - _$EmptyModelQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(EmptyModelQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(EmptyModelQuerySnapshot._fromQuerySnapshot); - } - - @override - EmptyModelQuery limit(int limit) { - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - EmptyModelQuery limitToLast(int limit) { - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - EmptyModelQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EmptyModelQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - EmptyModelQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EmptyModelDocumentSnapshot? startAtDocument, - EmptyModelDocumentSnapshot? endAtDocument, - EmptyModelDocumentSnapshot? endBeforeDocument, - EmptyModelDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - EmptyModelQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - EmptyModelDocumentSnapshot? startAtDocument, - EmptyModelDocumentSnapshot? endAtDocument, - EmptyModelDocumentSnapshot? endBeforeDocument, - EmptyModelDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$EmptyModelQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$EmptyModelQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { - EmptyModelDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference( - snapshot.reference, - ); - } - - @override - final EmptyModel? data; -} - -class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot { - EmptyModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory EmptyModelQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(EmptyModelQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - EmptyModelDocumentSnapshot._, - ); - }).toList(); - - return EmptyModelQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class EmptyModelQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements EmptyModelDocumentSnapshot { - EmptyModelQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final EmptyModel data; - - @override - EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class OptionalJsonCollectionReference - implements - OptionalJsonQuery, - FirestoreCollectionReference { - factory OptionalJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$OptionalJsonCollectionReference; - - static OptionalJson fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return _$OptionalJsonFromJson(snapshot.data()!); - } - - static Map toFirestore( - OptionalJson value, - SetOptions? options, - ) { - return _$OptionalJsonToJson(value); - } - - @override - CollectionReference get reference; - - @override - OptionalJsonDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(OptionalJson value); -} - -class _$OptionalJsonCollectionReference extends _$OptionalJsonQuery - implements OptionalJsonCollectionReference { - factory _$OptionalJsonCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$OptionalJsonCollectionReference._( - firestore.collection('root').withConverter( - fromFirestore: OptionalJsonCollectionReference.fromFirestore, - toFirestore: OptionalJsonCollectionReference.toFirestore, - ), - ); - } - - _$OptionalJsonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - OptionalJsonDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return OptionalJsonDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(OptionalJson value) { - return reference - .add(value) - .then((ref) => OptionalJsonDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$OptionalJsonCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class OptionalJsonDocumentReference extends FirestoreDocumentReference< - OptionalJson, OptionalJsonDocumentSnapshot> { - factory OptionalJsonDocumentReference( - DocumentReference reference) = - _$OptionalJsonDocumentReference; - - DocumentReference get reference; - - /// A reference to the [OptionalJsonCollectionReference] containing this document. - OptionalJsonCollectionReference get parent { - return _$OptionalJsonCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - OptionalJson model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - OptionalJson model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - OptionalJson model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - OptionalJson, - OptionalJsonDocumentSnapshot> implements OptionalJsonDocumentReference { - _$OptionalJsonDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [OptionalJsonCollectionReference] containing this document. - OptionalJsonCollectionReference get parent { - return _$OptionalJsonCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(OptionalJsonDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(OptionalJsonDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(OptionalJsonDocumentSnapshot._); - } - - Future set( - OptionalJson model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ..._$OptionalJsonToJson(model), - if (valueFieldValue != null) - _$OptionalJsonFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - OptionalJson model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ..._$OptionalJsonToJson(model), - if (valueFieldValue != null) - _$OptionalJsonFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - OptionalJson model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ..._$OptionalJsonToJson(model), - if (valueFieldValue != null) - _$OptionalJsonFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class OptionalJsonQuery - implements QueryReference { - @override - OptionalJsonQuery limit(int limit); - - @override - OptionalJsonQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - OptionalJsonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - OptionalJsonQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - OptionalJsonQuery whereValue({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - OptionalJsonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - OptionalJsonDocumentSnapshot? startAtDocument, - OptionalJsonDocumentSnapshot? endAtDocument, - OptionalJsonDocumentSnapshot? endBeforeDocument, - OptionalJsonDocumentSnapshot? startAfterDocument, - }); - - OptionalJsonQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - OptionalJsonDocumentSnapshot? startAtDocument, - OptionalJsonDocumentSnapshot? endAtDocument, - OptionalJsonDocumentSnapshot? endBeforeDocument, - OptionalJsonDocumentSnapshot? startAfterDocument, - }); - - OptionalJsonQuery orderByValue({ - bool descending = false, - int startAt, - int startAfter, - int endAt, - int endBefore, - OptionalJsonDocumentSnapshot? startAtDocument, - OptionalJsonDocumentSnapshot? endAtDocument, - OptionalJsonDocumentSnapshot? endBeforeDocument, - OptionalJsonDocumentSnapshot? startAfterDocument, - }); -} - -class _$OptionalJsonQuery - extends QueryReference - implements OptionalJsonQuery { - _$OptionalJsonQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(OptionalJsonQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(OptionalJsonQuerySnapshot._fromQuerySnapshot); - } - - @override - OptionalJsonQuery limit(int limit) { - return _$OptionalJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - OptionalJsonQuery limitToLast(int limit) { - return _$OptionalJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - OptionalJsonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$OptionalJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - OptionalJsonQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$OptionalJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - OptionalJsonQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$OptionalJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$OptionalJsonFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$OptionalJsonPerFieldToJson.value(isEqualTo as int) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$OptionalJsonPerFieldToJson.value(isNotEqualTo as int) - : null, - isLessThan: isLessThan != null - ? _$OptionalJsonPerFieldToJson.value(isLessThan as int) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$OptionalJsonPerFieldToJson.value(isLessThanOrEqualTo as int) - : null, - isGreaterThan: isGreaterThan != null - ? _$OptionalJsonPerFieldToJson.value(isGreaterThan as int) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$OptionalJsonPerFieldToJson.value(isGreaterThanOrEqualTo as int) - : null, - whereIn: whereIn?.map((e) => _$OptionalJsonPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$OptionalJsonPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - OptionalJsonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - OptionalJsonDocumentSnapshot? startAtDocument, - OptionalJsonDocumentSnapshot? endAtDocument, - OptionalJsonDocumentSnapshot? endBeforeDocument, - OptionalJsonDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$OptionalJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - OptionalJsonQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - OptionalJsonDocumentSnapshot? startAtDocument, - OptionalJsonDocumentSnapshot? endAtDocument, - OptionalJsonDocumentSnapshot? endBeforeDocument, - OptionalJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$OptionalJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - OptionalJsonQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - OptionalJsonDocumentSnapshot? startAtDocument, - OptionalJsonDocumentSnapshot? endAtDocument, - OptionalJsonDocumentSnapshot? endBeforeDocument, - OptionalJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$OptionalJsonFieldMap['value']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$OptionalJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$OptionalJsonQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class OptionalJsonDocumentSnapshot - extends FirestoreDocumentSnapshot { - OptionalJsonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - OptionalJsonDocumentReference get reference { - return OptionalJsonDocumentReference( - snapshot.reference, - ); - } - - @override - final OptionalJson? data; -} - -class OptionalJsonQuerySnapshot extends FirestoreQuerySnapshot { - OptionalJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory OptionalJsonQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(OptionalJsonQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - OptionalJsonDocumentSnapshot._, - ); - }).toList(); - - return OptionalJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - OptionalJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class OptionalJsonQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements OptionalJsonDocumentSnapshot { - OptionalJsonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final OptionalJson data; - - @override - OptionalJsonDocumentReference get reference { - return OptionalJsonDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class MixedJsonCollectionReference - implements - MixedJsonQuery, - FirestoreCollectionReference { - factory MixedJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$MixedJsonCollectionReference; - - static MixedJson fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return MixedJson.fromJson(snapshot.data()!); - } - - static Map toFirestore( - MixedJson value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - MixedJsonDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(MixedJson value); -} - -class _$MixedJsonCollectionReference extends _$MixedJsonQuery - implements MixedJsonCollectionReference { - factory _$MixedJsonCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$MixedJsonCollectionReference._( - firestore.collection('root').withConverter( - fromFirestore: MixedJsonCollectionReference.fromFirestore, - toFirestore: MixedJsonCollectionReference.toFirestore, - ), - ); - } - - _$MixedJsonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - MixedJsonDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return MixedJsonDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(MixedJson value) { - return reference.add(value).then((ref) => MixedJsonDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$MixedJsonCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class MixedJsonDocumentReference - extends FirestoreDocumentReference { - factory MixedJsonDocumentReference(DocumentReference reference) = - _$MixedJsonDocumentReference; - - DocumentReference get reference; - - /// A reference to the [MixedJsonCollectionReference] containing this document. - MixedJsonCollectionReference get parent { - return _$MixedJsonCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - MixedJson model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - MixedJson model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - MixedJson model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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 - extends FirestoreDocumentReference - implements MixedJsonDocumentReference { - _$MixedJsonDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [MixedJsonCollectionReference] containing this document. - MixedJsonCollectionReference get parent { - return _$MixedJsonCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(MixedJsonDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(MixedJsonDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(MixedJsonDocumentSnapshot._); - } - - Future set( - MixedJson model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$MixedJsonFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - MixedJson model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$MixedJsonFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - MixedJson model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$MixedJsonFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class MixedJsonQuery - implements QueryReference { - @override - MixedJsonQuery limit(int limit); - - @override - MixedJsonQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - MixedJsonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MixedJsonQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - MixedJsonQuery whereValue({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - MixedJsonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - MixedJsonDocumentSnapshot? startAtDocument, - MixedJsonDocumentSnapshot? endAtDocument, - MixedJsonDocumentSnapshot? endBeforeDocument, - MixedJsonDocumentSnapshot? startAfterDocument, - }); - - MixedJsonQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - MixedJsonDocumentSnapshot? startAtDocument, - MixedJsonDocumentSnapshot? endAtDocument, - MixedJsonDocumentSnapshot? endBeforeDocument, - MixedJsonDocumentSnapshot? startAfterDocument, - }); - - MixedJsonQuery orderByValue({ - bool descending = false, - int startAt, - int startAfter, - int endAt, - int endBefore, - MixedJsonDocumentSnapshot? startAtDocument, - MixedJsonDocumentSnapshot? endAtDocument, - MixedJsonDocumentSnapshot? endBeforeDocument, - MixedJsonDocumentSnapshot? startAfterDocument, - }); -} - -class _$MixedJsonQuery extends QueryReference - implements MixedJsonQuery { - _$MixedJsonQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(MixedJsonQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(MixedJsonQuerySnapshot._fromQuerySnapshot); - } - - @override - MixedJsonQuery limit(int limit) { - return _$MixedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - MixedJsonQuery limitToLast(int limit) { - return _$MixedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - MixedJsonQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MixedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MixedJsonQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MixedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MixedJsonQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$MixedJsonQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$MixedJsonFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$MixedJsonPerFieldToJson.value(isEqualTo as int) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$MixedJsonPerFieldToJson.value(isNotEqualTo as int) - : null, - isLessThan: isLessThan != null - ? _$MixedJsonPerFieldToJson.value(isLessThan as int) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$MixedJsonPerFieldToJson.value(isLessThanOrEqualTo as int) - : null, - isGreaterThan: isGreaterThan != null - ? _$MixedJsonPerFieldToJson.value(isGreaterThan as int) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MixedJsonPerFieldToJson.value(isGreaterThanOrEqualTo as int) - : null, - whereIn: whereIn?.map((e) => _$MixedJsonPerFieldToJson.value(e)), - whereNotIn: whereNotIn?.map((e) => _$MixedJsonPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - MixedJsonQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MixedJsonDocumentSnapshot? startAtDocument, - MixedJsonDocumentSnapshot? endAtDocument, - MixedJsonDocumentSnapshot? endBeforeDocument, - MixedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MixedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MixedJsonQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MixedJsonDocumentSnapshot? startAtDocument, - MixedJsonDocumentSnapshot? endAtDocument, - MixedJsonDocumentSnapshot? endBeforeDocument, - MixedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MixedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - MixedJsonQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - MixedJsonDocumentSnapshot? startAtDocument, - MixedJsonDocumentSnapshot? endAtDocument, - MixedJsonDocumentSnapshot? endBeforeDocument, - MixedJsonDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$MixedJsonFieldMap['value']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$MixedJsonQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$MixedJsonQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class MixedJsonDocumentSnapshot extends FirestoreDocumentSnapshot { - MixedJsonDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - MixedJsonDocumentReference get reference { - return MixedJsonDocumentReference( - snapshot.reference, - ); - } - - @override - final MixedJson? data; -} - -class MixedJsonQuerySnapshot - extends FirestoreQuerySnapshot { - MixedJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory MixedJsonQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(MixedJsonQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - MixedJsonDocumentSnapshot._, - ); - }).toList(); - - return MixedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - MixedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class MixedJsonQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements MixedJsonDocumentSnapshot { - MixedJsonQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final MixedJson data; - - @override - MixedJsonDocumentReference get reference { - return MixedJsonDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class RootCollectionReference - implements - RootQuery, - FirestoreCollectionReference { - factory RootCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$RootCollectionReference; - - static Root fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return Root.fromJson(snapshot.data()!); - } - - static Map toFirestore( - Root value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - RootDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Root value); -} - -class _$RootCollectionReference extends _$RootQuery - implements RootCollectionReference { - factory _$RootCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$RootCollectionReference._( - firestore.collection('root').withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - _$RootCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - RootDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return RootDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Root value) { - return reference.add(value).then((ref) => RootDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$RootCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class RootDocumentReference - extends FirestoreDocumentReference { - factory RootDocumentReference(DocumentReference reference) = - _$RootDocumentReference; - - DocumentReference get reference; - - /// A reference to the [RootCollectionReference] containing this document. - RootCollectionReference get parent { - return _$RootCollectionReference(reference.firestore); - } - - late final SubCollectionReference sub = _$SubCollectionReference( - reference, - ); - - late final AsCamelCaseCollectionReference asCamelCase = - _$AsCamelCaseCollectionReference( - reference, - ); - - late final CustomSubNameCollectionReference thisIsACustomName = - _$CustomSubNameCollectionReference( - reference, - ); - - late final ThisIsACustomPrefixCollectionReference customClassPrefix = - _$ThisIsACustomPrefixCollectionReference( - reference, - ); - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Root model, { - SetOptions? options, - FieldValue nonNullableFieldValue, - FieldValue nullableFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Root model, { - SetOptions? options, - FieldValue nonNullableFieldValue, - FieldValue nullableFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Root model, { - SetOptions? options, - FieldValue nonNullableFieldValue, - FieldValue nullableFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String nonNullable, - FieldValue nonNullableFieldValue, - int? nullable, - FieldValue nullableFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - String nonNullable, - FieldValue nonNullableFieldValue, - 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 - extends FirestoreDocumentReference - implements RootDocumentReference { - _$RootDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [RootCollectionReference] containing this document. - RootCollectionReference get parent { - return _$RootCollectionReference(reference.firestore); - } - - late final SubCollectionReference sub = _$SubCollectionReference( - reference, - ); - - late final AsCamelCaseCollectionReference asCamelCase = - _$AsCamelCaseCollectionReference( - reference, - ); - - late final CustomSubNameCollectionReference thisIsACustomName = - _$CustomSubNameCollectionReference( - reference, - ); - - late final ThisIsACustomPrefixCollectionReference customClassPrefix = - _$ThisIsACustomPrefixCollectionReference( - reference, - ); - - @override - Stream snapshots() { - return reference.snapshots().map(RootDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(RootDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(RootDocumentSnapshot._); - } - - Future set( - Root model, { - SetOptions? options, - FieldValue? nonNullableFieldValue, - FieldValue? nullableFieldValue, - }) async { - final json = { - ...model.toJson(), - if (nonNullableFieldValue != null) - _$RootFieldMap['nonNullable']!: nonNullableFieldValue, - if (nullableFieldValue != null) - _$RootFieldMap['nullable']!: nullableFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Root model, { - SetOptions? options, - FieldValue? nonNullableFieldValue, - FieldValue? nullableFieldValue, - }) { - final json = { - ...model.toJson(), - if (nonNullableFieldValue != null) - _$RootFieldMap['nonNullable']!: nonNullableFieldValue, - if (nullableFieldValue != null) - _$RootFieldMap['nullable']!: nullableFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Root model, { - SetOptions? options, - FieldValue? nonNullableFieldValue, - FieldValue? nullableFieldValue, - }) { - final json = { - ...model.toJson(), - if (nonNullableFieldValue != null) - _$RootFieldMap['nonNullable']!: nonNullableFieldValue, - if (nullableFieldValue != null) - _$RootFieldMap['nullable']!: nullableFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? nonNullable = _sentinel, - FieldValue? nonNullableFieldValue, - Object? nullable = _sentinel, - FieldValue? nullableFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class RootQuery implements QueryReference { - @override - RootQuery limit(int limit); - - @override - RootQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - RootQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - RootQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - RootQuery whereNonNullable({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - RootQuery whereNullable({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - RootQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - RootDocumentSnapshot? startAtDocument, - RootDocumentSnapshot? endAtDocument, - RootDocumentSnapshot? endBeforeDocument, - RootDocumentSnapshot? startAfterDocument, - }); - - RootQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - RootDocumentSnapshot? startAtDocument, - RootDocumentSnapshot? endAtDocument, - RootDocumentSnapshot? endBeforeDocument, - RootDocumentSnapshot? startAfterDocument, - }); - - RootQuery orderByNonNullable({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - RootDocumentSnapshot? startAtDocument, - RootDocumentSnapshot? endAtDocument, - RootDocumentSnapshot? endBeforeDocument, - RootDocumentSnapshot? startAfterDocument, - }); - - RootQuery orderByNullable({ - bool descending = false, - int? startAt, - int? startAfter, - int? endAt, - int? endBefore, - RootDocumentSnapshot? startAtDocument, - RootDocumentSnapshot? endAtDocument, - RootDocumentSnapshot? endBeforeDocument, - RootDocumentSnapshot? startAfterDocument, - }); -} - -class _$RootQuery extends QueryReference - implements RootQuery { - _$RootQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(RootQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(RootQuerySnapshot._fromQuerySnapshot); - } - - @override - RootQuery limit(int limit) { - return _$RootQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - RootQuery limitToLast(int limit) { - return _$RootQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - RootQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$RootQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - RootQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$RootQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - RootQuery whereNonNullable({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$RootQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$RootFieldMap['nonNullable']!, - isEqualTo: isEqualTo != _sentinel - ? _$RootPerFieldToJson.nonNullable(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$RootPerFieldToJson.nonNullable(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$RootPerFieldToJson.nonNullable(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$RootPerFieldToJson.nonNullable(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$RootPerFieldToJson.nonNullable(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$RootPerFieldToJson.nonNullable(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$RootPerFieldToJson.nonNullable(e)), - whereNotIn: whereNotIn?.map((e) => _$RootPerFieldToJson.nonNullable(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - RootQuery whereNullable({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$RootQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$RootFieldMap['nullable']!, - isEqualTo: isEqualTo != _sentinel - ? _$RootPerFieldToJson.nullable(isEqualTo as int?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$RootPerFieldToJson.nullable(isNotEqualTo as int?) - : null, - isLessThan: isLessThan != null - ? _$RootPerFieldToJson.nullable(isLessThan as int?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$RootPerFieldToJson.nullable(isLessThanOrEqualTo as int?) - : null, - isGreaterThan: isGreaterThan != null - ? _$RootPerFieldToJson.nullable(isGreaterThan as int?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$RootPerFieldToJson.nullable(isGreaterThanOrEqualTo as int?) - : null, - whereIn: whereIn?.map((e) => _$RootPerFieldToJson.nullable(e)), - whereNotIn: whereNotIn?.map((e) => _$RootPerFieldToJson.nullable(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - RootQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - RootDocumentSnapshot? startAtDocument, - RootDocumentSnapshot? endAtDocument, - RootDocumentSnapshot? endBeforeDocument, - RootDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$RootQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - RootQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - RootDocumentSnapshot? startAtDocument, - RootDocumentSnapshot? endAtDocument, - RootDocumentSnapshot? endBeforeDocument, - RootDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$RootQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - RootQuery orderByNonNullable({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - RootDocumentSnapshot? startAtDocument, - RootDocumentSnapshot? endAtDocument, - RootDocumentSnapshot? endBeforeDocument, - RootDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$RootFieldMap['nonNullable']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$RootQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - RootQuery orderByNullable({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - RootDocumentSnapshot? startAtDocument, - RootDocumentSnapshot? endAtDocument, - RootDocumentSnapshot? endBeforeDocument, - RootDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$RootFieldMap['nullable']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$RootQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$RootQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class RootDocumentSnapshot extends FirestoreDocumentSnapshot { - RootDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - RootDocumentReference get reference { - return RootDocumentReference( - snapshot.reference, - ); - } - - @override - final Root? data; -} - -class RootQuerySnapshot - extends FirestoreQuerySnapshot { - RootQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory RootQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(RootQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - RootDocumentSnapshot._, - ); - }).toList(); - - return RootQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange _decodeDocumentChange( - DocumentChange docChange, - RootDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class RootQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements RootDocumentSnapshot { - RootQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Root data; - - @override - RootDocumentReference get reference { - return RootDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class SubCollectionReference - implements SubQuery, FirestoreCollectionReference { - factory SubCollectionReference( - DocumentReference parent, - ) = _$SubCollectionReference; - - static Sub fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return Sub.fromJson(snapshot.data()!); - } - - static Map toFirestore( - Sub value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - /// A reference to the containing [RootDocumentReference] if this is a subcollection. - RootDocumentReference get parent; - - @override - SubDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(Sub value); -} - -class _$SubCollectionReference extends _$SubQuery - implements SubCollectionReference { - factory _$SubCollectionReference( - DocumentReference parent, - ) { - return _$SubCollectionReference._( - RootDocumentReference(parent), - parent.collection('sub').withConverter( - fromFirestore: SubCollectionReference.fromFirestore, - toFirestore: SubCollectionReference.toFirestore, - ), - ); - } - - _$SubCollectionReference._( - this.parent, - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - @override - final RootDocumentReference parent; - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - SubDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return SubDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(Sub value) { - return reference.add(value).then((ref) => SubDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$SubCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class SubDocumentReference - extends FirestoreDocumentReference { - factory SubDocumentReference(DocumentReference reference) = - _$SubDocumentReference; - - DocumentReference get reference; - - /// A reference to the [SubCollectionReference] containing this document. - SubCollectionReference get parent { - return _$SubCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - Sub model, { - SetOptions? options, - FieldValue nonNullableFieldValue, - FieldValue nullableFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - Sub model, { - SetOptions? options, - FieldValue nonNullableFieldValue, - FieldValue nullableFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - Sub model, { - SetOptions? options, - FieldValue nonNullableFieldValue, - FieldValue nullableFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - String nonNullable, - FieldValue nonNullableFieldValue, - int? nullable, - FieldValue nullableFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - String nonNullable, - FieldValue nonNullableFieldValue, - 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 - extends FirestoreDocumentReference - implements SubDocumentReference { - _$SubDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [SubCollectionReference] containing this document. - SubCollectionReference get parent { - return _$SubCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots() { - return reference.snapshots().map(SubDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(SubDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(SubDocumentSnapshot._); - } - - Future set( - Sub model, { - SetOptions? options, - FieldValue? nonNullableFieldValue, - FieldValue? nullableFieldValue, - }) async { - final json = { - ...model.toJson(), - if (nonNullableFieldValue != null) - _$SubFieldMap['nonNullable']!: nonNullableFieldValue, - if (nullableFieldValue != null) - _$SubFieldMap['nullable']!: nullableFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - Sub model, { - SetOptions? options, - FieldValue? nonNullableFieldValue, - FieldValue? nullableFieldValue, - }) { - final json = { - ...model.toJson(), - if (nonNullableFieldValue != null) - _$SubFieldMap['nonNullable']!: nonNullableFieldValue, - if (nullableFieldValue != null) - _$SubFieldMap['nullable']!: nullableFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - Sub model, { - SetOptions? options, - FieldValue? nonNullableFieldValue, - FieldValue? nullableFieldValue, - }) { - final json = { - ...model.toJson(), - if (nonNullableFieldValue != null) - _$SubFieldMap['nonNullable']!: nonNullableFieldValue, - if (nullableFieldValue != null) - _$SubFieldMap['nullable']!: nullableFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? nonNullable = _sentinel, - FieldValue? nonNullableFieldValue, - Object? nullable = _sentinel, - FieldValue? nullableFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class SubQuery implements QueryReference { - @override - SubQuery limit(int limit); - - @override - SubQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - SubQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - SubQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - SubQuery whereNonNullable({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - SubQuery whereNullable({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - SubQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - SubDocumentSnapshot? startAtDocument, - SubDocumentSnapshot? endAtDocument, - SubDocumentSnapshot? endBeforeDocument, - SubDocumentSnapshot? startAfterDocument, - }); - - SubQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - SubDocumentSnapshot? startAtDocument, - SubDocumentSnapshot? endAtDocument, - SubDocumentSnapshot? endBeforeDocument, - SubDocumentSnapshot? startAfterDocument, - }); - - SubQuery orderByNonNullable({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - SubDocumentSnapshot? startAtDocument, - SubDocumentSnapshot? endAtDocument, - SubDocumentSnapshot? endBeforeDocument, - SubDocumentSnapshot? startAfterDocument, - }); - - SubQuery orderByNullable({ - bool descending = false, - int? startAt, - int? startAfter, - int? endAt, - int? endBefore, - SubDocumentSnapshot? startAtDocument, - SubDocumentSnapshot? endAtDocument, - SubDocumentSnapshot? endBeforeDocument, - SubDocumentSnapshot? startAfterDocument, - }); -} - -class _$SubQuery extends QueryReference - implements SubQuery { - _$SubQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(SubQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(SubQuerySnapshot._fromQuerySnapshot); - } - - @override - SubQuery limit(int limit) { - return _$SubQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - SubQuery limitToLast(int limit) { - return _$SubQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - SubQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$SubQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - SubQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$SubQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - SubQuery whereNonNullable({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$SubQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$SubFieldMap['nonNullable']!, - isEqualTo: isEqualTo != _sentinel - ? _$SubPerFieldToJson.nonNullable(isEqualTo as String) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$SubPerFieldToJson.nonNullable(isNotEqualTo as String) - : null, - isLessThan: isLessThan != null - ? _$SubPerFieldToJson.nonNullable(isLessThan as String) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$SubPerFieldToJson.nonNullable(isLessThanOrEqualTo as String) - : null, - isGreaterThan: isGreaterThan != null - ? _$SubPerFieldToJson.nonNullable(isGreaterThan as String) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$SubPerFieldToJson.nonNullable(isGreaterThanOrEqualTo as String) - : null, - whereIn: whereIn?.map((e) => _$SubPerFieldToJson.nonNullable(e)), - whereNotIn: whereNotIn?.map((e) => _$SubPerFieldToJson.nonNullable(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - SubQuery whereNullable({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$SubQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$SubFieldMap['nullable']!, - isEqualTo: isEqualTo != _sentinel - ? _$SubPerFieldToJson.nullable(isEqualTo as int?) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$SubPerFieldToJson.nullable(isNotEqualTo as int?) - : null, - isLessThan: isLessThan != null - ? _$SubPerFieldToJson.nullable(isLessThan as int?) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$SubPerFieldToJson.nullable(isLessThanOrEqualTo as int?) - : null, - isGreaterThan: isGreaterThan != null - ? _$SubPerFieldToJson.nullable(isGreaterThan as int?) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$SubPerFieldToJson.nullable(isGreaterThanOrEqualTo as int?) - : null, - whereIn: whereIn?.map((e) => _$SubPerFieldToJson.nullable(e)), - whereNotIn: whereNotIn?.map((e) => _$SubPerFieldToJson.nullable(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - SubQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - SubDocumentSnapshot? startAtDocument, - SubDocumentSnapshot? endAtDocument, - SubDocumentSnapshot? endBeforeDocument, - SubDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$SubQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - SubQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - SubDocumentSnapshot? startAtDocument, - SubDocumentSnapshot? endAtDocument, - SubDocumentSnapshot? endBeforeDocument, - SubDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$SubQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - SubQuery orderByNonNullable({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - SubDocumentSnapshot? startAtDocument, - SubDocumentSnapshot? endAtDocument, - SubDocumentSnapshot? endBeforeDocument, - SubDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$SubFieldMap['nonNullable']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$SubQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - SubQuery orderByNullable({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - SubDocumentSnapshot? startAtDocument, - SubDocumentSnapshot? endAtDocument, - SubDocumentSnapshot? endBeforeDocument, - SubDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$SubFieldMap['nullable']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$SubQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$SubQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class SubDocumentSnapshot extends FirestoreDocumentSnapshot { - SubDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - SubDocumentReference get reference { - return SubDocumentReference( - snapshot.reference, - ); - } - - @override - final Sub? data; -} - -class SubQuerySnapshot - extends FirestoreQuerySnapshot { - SubQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory SubQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(SubQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - SubDocumentSnapshot._, - ); - }).toList(); - - return SubQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange _decodeDocumentChange( - DocumentChange docChange, - SubDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class SubQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements SubDocumentSnapshot { - SubQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final Sub data; - - @override - SubDocumentReference get reference { - return SubDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class AsCamelCaseCollectionReference - implements - AsCamelCaseQuery, - FirestoreCollectionReference { - factory AsCamelCaseCollectionReference( - DocumentReference parent, - ) = _$AsCamelCaseCollectionReference; - - static AsCamelCase fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return AsCamelCase.fromJson(snapshot.data()!); - } - - static Map toFirestore( - AsCamelCase value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - /// A reference to the containing [RootDocumentReference] if this is a subcollection. - RootDocumentReference get parent; - - @override - AsCamelCaseDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(AsCamelCase value); -} - -class _$AsCamelCaseCollectionReference extends _$AsCamelCaseQuery - implements AsCamelCaseCollectionReference { - factory _$AsCamelCaseCollectionReference( - DocumentReference parent, - ) { - return _$AsCamelCaseCollectionReference._( - RootDocumentReference(parent), - parent.collection('as-camel-case').withConverter( - fromFirestore: AsCamelCaseCollectionReference.fromFirestore, - toFirestore: AsCamelCaseCollectionReference.toFirestore, - ), - ); - } - - _$AsCamelCaseCollectionReference._( - this.parent, - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - @override - final RootDocumentReference parent; - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - AsCamelCaseDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return AsCamelCaseDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(AsCamelCase value) { - return reference - .add(value) - .then((ref) => AsCamelCaseDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$AsCamelCaseCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class AsCamelCaseDocumentReference extends FirestoreDocumentReference< - AsCamelCase, AsCamelCaseDocumentSnapshot> { - factory AsCamelCaseDocumentReference( - DocumentReference reference) = - _$AsCamelCaseDocumentReference; - - DocumentReference get reference; - - /// A reference to the [AsCamelCaseCollectionReference] containing this document. - AsCamelCaseCollectionReference get parent { - return _$AsCamelCaseCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - AsCamelCase model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - AsCamelCase model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - AsCamelCase model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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 - extends FirestoreDocumentReference - implements AsCamelCaseDocumentReference { - _$AsCamelCaseDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [AsCamelCaseCollectionReference] containing this document. - AsCamelCaseCollectionReference get parent { - return _$AsCamelCaseCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots() { - return reference.snapshots().map(AsCamelCaseDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(AsCamelCaseDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(AsCamelCaseDocumentSnapshot._); - } - - Future set( - AsCamelCase model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$AsCamelCaseFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - AsCamelCase model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$AsCamelCaseFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - AsCamelCase model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$AsCamelCaseFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class AsCamelCaseQuery - implements QueryReference { - @override - AsCamelCaseQuery limit(int limit); - - @override - AsCamelCaseQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - AsCamelCaseQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - AsCamelCaseQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - AsCamelCaseQuery whereValue({ - num? isEqualTo, - num? isNotEqualTo, - num? isLessThan, - num? isLessThanOrEqualTo, - num? isGreaterThan, - num? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - AsCamelCaseQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - AsCamelCaseDocumentSnapshot? startAtDocument, - AsCamelCaseDocumentSnapshot? endAtDocument, - AsCamelCaseDocumentSnapshot? endBeforeDocument, - AsCamelCaseDocumentSnapshot? startAfterDocument, - }); - - AsCamelCaseQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - AsCamelCaseDocumentSnapshot? startAtDocument, - AsCamelCaseDocumentSnapshot? endAtDocument, - AsCamelCaseDocumentSnapshot? endBeforeDocument, - AsCamelCaseDocumentSnapshot? startAfterDocument, - }); - - AsCamelCaseQuery orderByValue({ - bool descending = false, - num startAt, - num startAfter, - num endAt, - num endBefore, - AsCamelCaseDocumentSnapshot? startAtDocument, - AsCamelCaseDocumentSnapshot? endAtDocument, - AsCamelCaseDocumentSnapshot? endBeforeDocument, - AsCamelCaseDocumentSnapshot? startAfterDocument, - }); -} - -class _$AsCamelCaseQuery - extends QueryReference - implements AsCamelCaseQuery { - _$AsCamelCaseQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(AsCamelCaseQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(AsCamelCaseQuerySnapshot._fromQuerySnapshot); - } - - @override - AsCamelCaseQuery limit(int limit) { - return _$AsCamelCaseQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - AsCamelCaseQuery limitToLast(int limit) { - return _$AsCamelCaseQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - AsCamelCaseQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$AsCamelCaseQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - AsCamelCaseQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$AsCamelCaseQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - AsCamelCaseQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$AsCamelCaseQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$AsCamelCaseFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$AsCamelCasePerFieldToJson.value(isEqualTo as num) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$AsCamelCasePerFieldToJson.value(isNotEqualTo as num) - : null, - isLessThan: isLessThan != null - ? _$AsCamelCasePerFieldToJson.value(isLessThan as num) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$AsCamelCasePerFieldToJson.value(isLessThanOrEqualTo as num) - : null, - isGreaterThan: isGreaterThan != null - ? _$AsCamelCasePerFieldToJson.value(isGreaterThan as num) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$AsCamelCasePerFieldToJson.value(isGreaterThanOrEqualTo as num) - : null, - whereIn: whereIn?.map((e) => _$AsCamelCasePerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$AsCamelCasePerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - AsCamelCaseQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - AsCamelCaseDocumentSnapshot? startAtDocument, - AsCamelCaseDocumentSnapshot? endAtDocument, - AsCamelCaseDocumentSnapshot? endBeforeDocument, - AsCamelCaseDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$AsCamelCaseQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - AsCamelCaseQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - AsCamelCaseDocumentSnapshot? startAtDocument, - AsCamelCaseDocumentSnapshot? endAtDocument, - AsCamelCaseDocumentSnapshot? endBeforeDocument, - AsCamelCaseDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$AsCamelCaseQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - AsCamelCaseQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - AsCamelCaseDocumentSnapshot? startAtDocument, - AsCamelCaseDocumentSnapshot? endAtDocument, - AsCamelCaseDocumentSnapshot? endBeforeDocument, - AsCamelCaseDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$AsCamelCaseFieldMap['value']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$AsCamelCaseQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$AsCamelCaseQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class AsCamelCaseDocumentSnapshot - extends FirestoreDocumentSnapshot { - AsCamelCaseDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - AsCamelCaseDocumentReference get reference { - return AsCamelCaseDocumentReference( - snapshot.reference, - ); - } - - @override - final AsCamelCase? data; -} - -class AsCamelCaseQuerySnapshot extends FirestoreQuerySnapshot { - AsCamelCaseQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory AsCamelCaseQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(AsCamelCaseQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - AsCamelCaseDocumentSnapshot._, - ); - }).toList(); - - return AsCamelCaseQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - AsCamelCaseDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class AsCamelCaseQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements AsCamelCaseDocumentSnapshot { - AsCamelCaseQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final AsCamelCase data; - - @override - AsCamelCaseDocumentReference get reference { - return AsCamelCaseDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class CustomSubNameCollectionReference - implements - CustomSubNameQuery, - FirestoreCollectionReference { - factory CustomSubNameCollectionReference( - DocumentReference parent, - ) = _$CustomSubNameCollectionReference; - - static CustomSubName fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return CustomSubName.fromJson(snapshot.data()!); - } - - static Map toFirestore( - CustomSubName value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - /// A reference to the containing [RootDocumentReference] if this is a subcollection. - RootDocumentReference get parent; - - @override - CustomSubNameDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(CustomSubName value); -} - -class _$CustomSubNameCollectionReference extends _$CustomSubNameQuery - implements CustomSubNameCollectionReference { - factory _$CustomSubNameCollectionReference( - DocumentReference parent, - ) { - return _$CustomSubNameCollectionReference._( - RootDocumentReference(parent), - parent.collection('custom-sub-name').withConverter( - fromFirestore: CustomSubNameCollectionReference.fromFirestore, - toFirestore: CustomSubNameCollectionReference.toFirestore, - ), - ); - } - - _$CustomSubNameCollectionReference._( - this.parent, - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - @override - final RootDocumentReference parent; - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - CustomSubNameDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return CustomSubNameDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(CustomSubName value) { - return reference - .add(value) - .then((ref) => CustomSubNameDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$CustomSubNameCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class CustomSubNameDocumentReference - extends FirestoreDocumentReference { - factory CustomSubNameDocumentReference( - DocumentReference reference) = - _$CustomSubNameDocumentReference; - - DocumentReference get reference; - - /// A reference to the [CustomSubNameCollectionReference] containing this document. - CustomSubNameCollectionReference get parent { - return _$CustomSubNameCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - CustomSubName model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - CustomSubName model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - CustomSubName model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - CustomSubName, - CustomSubNameDocumentSnapshot> implements CustomSubNameDocumentReference { - _$CustomSubNameDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [CustomSubNameCollectionReference] containing this document. - CustomSubNameCollectionReference get parent { - return _$CustomSubNameCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots() { - return reference.snapshots().map(CustomSubNameDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(CustomSubNameDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(CustomSubNameDocumentSnapshot._); - } - - Future set( - CustomSubName model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$CustomSubNameFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - CustomSubName model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$CustomSubNameFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - CustomSubName model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$CustomSubNameFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class CustomSubNameQuery - implements QueryReference { - @override - CustomSubNameQuery limit(int limit); - - @override - CustomSubNameQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - CustomSubNameQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - CustomSubNameQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - CustomSubNameQuery whereValue({ - num? isEqualTo, - num? isNotEqualTo, - num? isLessThan, - num? isLessThanOrEqualTo, - num? isGreaterThan, - num? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - CustomSubNameQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - CustomSubNameDocumentSnapshot? startAtDocument, - CustomSubNameDocumentSnapshot? endAtDocument, - CustomSubNameDocumentSnapshot? endBeforeDocument, - CustomSubNameDocumentSnapshot? startAfterDocument, - }); - - CustomSubNameQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - CustomSubNameDocumentSnapshot? startAtDocument, - CustomSubNameDocumentSnapshot? endAtDocument, - CustomSubNameDocumentSnapshot? endBeforeDocument, - CustomSubNameDocumentSnapshot? startAfterDocument, - }); - - CustomSubNameQuery orderByValue({ - bool descending = false, - num startAt, - num startAfter, - num endAt, - num endBefore, - CustomSubNameDocumentSnapshot? startAtDocument, - CustomSubNameDocumentSnapshot? endAtDocument, - CustomSubNameDocumentSnapshot? endBeforeDocument, - CustomSubNameDocumentSnapshot? startAfterDocument, - }); -} - -class _$CustomSubNameQuery - extends QueryReference - implements CustomSubNameQuery { - _$CustomSubNameQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(CustomSubNameQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(CustomSubNameQuerySnapshot._fromQuerySnapshot); - } - - @override - CustomSubNameQuery limit(int limit) { - return _$CustomSubNameQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - CustomSubNameQuery limitToLast(int limit) { - return _$CustomSubNameQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - CustomSubNameQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$CustomSubNameQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - CustomSubNameQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$CustomSubNameQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - CustomSubNameQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$CustomSubNameQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$CustomSubNameFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$CustomSubNamePerFieldToJson.value(isEqualTo as num) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$CustomSubNamePerFieldToJson.value(isNotEqualTo as num) - : null, - isLessThan: isLessThan != null - ? _$CustomSubNamePerFieldToJson.value(isLessThan as num) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$CustomSubNamePerFieldToJson.value(isLessThanOrEqualTo as num) - : null, - isGreaterThan: isGreaterThan != null - ? _$CustomSubNamePerFieldToJson.value(isGreaterThan as num) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$CustomSubNamePerFieldToJson.value(isGreaterThanOrEqualTo as num) - : null, - whereIn: whereIn?.map((e) => _$CustomSubNamePerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$CustomSubNamePerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - CustomSubNameQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - CustomSubNameDocumentSnapshot? startAtDocument, - CustomSubNameDocumentSnapshot? endAtDocument, - CustomSubNameDocumentSnapshot? endBeforeDocument, - CustomSubNameDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$CustomSubNameQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - CustomSubNameQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - CustomSubNameDocumentSnapshot? startAtDocument, - CustomSubNameDocumentSnapshot? endAtDocument, - CustomSubNameDocumentSnapshot? endBeforeDocument, - CustomSubNameDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$CustomSubNameQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - CustomSubNameQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - CustomSubNameDocumentSnapshot? startAtDocument, - CustomSubNameDocumentSnapshot? endAtDocument, - CustomSubNameDocumentSnapshot? endBeforeDocument, - CustomSubNameDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$CustomSubNameFieldMap['value']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$CustomSubNameQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$CustomSubNameQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class CustomSubNameDocumentSnapshot - extends FirestoreDocumentSnapshot { - CustomSubNameDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - CustomSubNameDocumentReference get reference { - return CustomSubNameDocumentReference( - snapshot.reference, - ); - } - - @override - final CustomSubName? data; -} - -class CustomSubNameQuerySnapshot extends FirestoreQuerySnapshot { - CustomSubNameQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory CustomSubNameQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(CustomSubNameQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - CustomSubNameDocumentSnapshot._, - ); - }).toList(); - - return CustomSubNameQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - CustomSubNameDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class CustomSubNameQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements CustomSubNameDocumentSnapshot { - CustomSubNameQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final CustomSubName data; - - @override - CustomSubNameDocumentReference get reference { - return CustomSubNameDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class ThisIsACustomPrefixCollectionReference - implements - ThisIsACustomPrefixQuery, - FirestoreCollectionReference { - factory ThisIsACustomPrefixCollectionReference( - DocumentReference parent, - ) = _$ThisIsACustomPrefixCollectionReference; - - static CustomClassPrefix fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return CustomClassPrefix.fromJson(snapshot.data()!); - } - - static Map toFirestore( - CustomClassPrefix value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - /// A reference to the containing [RootDocumentReference] if this is a subcollection. - RootDocumentReference get parent; - - @override - ThisIsACustomPrefixDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(CustomClassPrefix value); -} - -class _$ThisIsACustomPrefixCollectionReference - extends _$ThisIsACustomPrefixQuery - implements ThisIsACustomPrefixCollectionReference { - factory _$ThisIsACustomPrefixCollectionReference( - DocumentReference parent, - ) { - return _$ThisIsACustomPrefixCollectionReference._( - RootDocumentReference(parent), - parent.collection('custom-class-prefix').withConverter( - fromFirestore: ThisIsACustomPrefixCollectionReference.fromFirestore, - toFirestore: ThisIsACustomPrefixCollectionReference.toFirestore, - ), - ); - } - - _$ThisIsACustomPrefixCollectionReference._( - this.parent, - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - @override - final RootDocumentReference parent; - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - ThisIsACustomPrefixDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return ThisIsACustomPrefixDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(CustomClassPrefix value) { - return reference - .add(value) - .then((ref) => ThisIsACustomPrefixDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$ThisIsACustomPrefixCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class ThisIsACustomPrefixDocumentReference - extends FirestoreDocumentReference { - factory ThisIsACustomPrefixDocumentReference( - DocumentReference reference) = - _$ThisIsACustomPrefixDocumentReference; - - DocumentReference get reference; - - /// A reference to the [ThisIsACustomPrefixCollectionReference] containing this document. - ThisIsACustomPrefixCollectionReference get parent { - return _$ThisIsACustomPrefixCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - CustomClassPrefix model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - CustomClassPrefix model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - CustomClassPrefix model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - CustomClassPrefix, ThisIsACustomPrefixDocumentSnapshot> - implements ThisIsACustomPrefixDocumentReference { - _$ThisIsACustomPrefixDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [ThisIsACustomPrefixCollectionReference] containing this document. - ThisIsACustomPrefixCollectionReference get parent { - return _$ThisIsACustomPrefixCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: RootCollectionReference.fromFirestore, - toFirestore: RootCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots() { - return reference.snapshots().map(ThisIsACustomPrefixDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(ThisIsACustomPrefixDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction - .get(reference) - .then(ThisIsACustomPrefixDocumentSnapshot._); - } - - Future set( - CustomClassPrefix model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$CustomClassPrefixFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - CustomClassPrefix model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$CustomClassPrefixFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - CustomClassPrefix model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$CustomClassPrefixFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class ThisIsACustomPrefixQuery - implements - QueryReference { - @override - ThisIsACustomPrefixQuery limit(int limit); - - @override - ThisIsACustomPrefixQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - ThisIsACustomPrefixQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ThisIsACustomPrefixQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ThisIsACustomPrefixQuery whereValue({ - num? isEqualTo, - num? isNotEqualTo, - num? isLessThan, - num? isLessThanOrEqualTo, - num? isGreaterThan, - num? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - ThisIsACustomPrefixQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - ThisIsACustomPrefixDocumentSnapshot? startAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, - ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, - }); - - ThisIsACustomPrefixQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - ThisIsACustomPrefixDocumentSnapshot? startAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, - ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, - }); - - ThisIsACustomPrefixQuery orderByValue({ - bool descending = false, - num startAt, - num startAfter, - num endAt, - num endBefore, - ThisIsACustomPrefixDocumentSnapshot? startAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, - ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, - }); -} - -class _$ThisIsACustomPrefixQuery - extends QueryReference - implements ThisIsACustomPrefixQuery { - _$ThisIsACustomPrefixQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot); - } - - @override - ThisIsACustomPrefixQuery limit(int limit) { - return _$ThisIsACustomPrefixQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ThisIsACustomPrefixQuery limitToLast(int limit) { - return _$ThisIsACustomPrefixQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ThisIsACustomPrefixQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ThisIsACustomPrefixQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ThisIsACustomPrefixQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ThisIsACustomPrefixQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ThisIsACustomPrefixQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ThisIsACustomPrefixQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$CustomClassPrefixFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$CustomClassPrefixPerFieldToJson.value(isEqualTo as num) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$CustomClassPrefixPerFieldToJson.value(isNotEqualTo as num) - : null, - isLessThan: isLessThan != null - ? _$CustomClassPrefixPerFieldToJson.value(isLessThan as num) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$CustomClassPrefixPerFieldToJson - .value(isLessThanOrEqualTo as num) - : null, - isGreaterThan: isGreaterThan != null - ? _$CustomClassPrefixPerFieldToJson.value(isGreaterThan as num) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$CustomClassPrefixPerFieldToJson - .value(isGreaterThanOrEqualTo as num) - : null, - whereIn: - whereIn?.map((e) => _$CustomClassPrefixPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$CustomClassPrefixPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ThisIsACustomPrefixQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ThisIsACustomPrefixDocumentSnapshot? startAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, - ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ThisIsACustomPrefixQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ThisIsACustomPrefixQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ThisIsACustomPrefixDocumentSnapshot? startAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, - ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ThisIsACustomPrefixQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ThisIsACustomPrefixQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ThisIsACustomPrefixDocumentSnapshot? startAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endAtDocument, - ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, - ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$CustomClassPrefixFieldMap['value']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ThisIsACustomPrefixQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$ThisIsACustomPrefixQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class ThisIsACustomPrefixDocumentSnapshot - extends FirestoreDocumentSnapshot { - ThisIsACustomPrefixDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - ThisIsACustomPrefixDocumentReference get reference { - return ThisIsACustomPrefixDocumentReference( - snapshot.reference, - ); - } - - @override - final CustomClassPrefix? data; -} - -class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< - CustomClassPrefix, ThisIsACustomPrefixQueryDocumentSnapshot> { - ThisIsACustomPrefixQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(ThisIsACustomPrefixQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ThisIsACustomPrefixDocumentSnapshot._, - ); - }).toList(); - - return ThisIsACustomPrefixQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - ThisIsACustomPrefixDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> - docChanges; -} - -class ThisIsACustomPrefixQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements ThisIsACustomPrefixDocumentSnapshot { - ThisIsACustomPrefixQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final CustomClassPrefix data; - - @override - ThisIsACustomPrefixDocumentReference get reference { - return ThisIsACustomPrefixDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class ExplicitPathCollectionReference - implements - ExplicitPathQuery, - FirestoreCollectionReference { - factory ExplicitPathCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ExplicitPathCollectionReference; - - static ExplicitPath fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return ExplicitPath.fromJson(snapshot.data()!); - } - - static Map toFirestore( - ExplicitPath value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - ExplicitPathDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(ExplicitPath value); -} - -class _$ExplicitPathCollectionReference extends _$ExplicitPathQuery - implements ExplicitPathCollectionReference { - factory _$ExplicitPathCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$ExplicitPathCollectionReference._( - firestore.collection('root/doc/path').withConverter( - fromFirestore: ExplicitPathCollectionReference.fromFirestore, - toFirestore: ExplicitPathCollectionReference.toFirestore, - ), - ); - } - - _$ExplicitPathCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - ExplicitPathDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return ExplicitPathDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(ExplicitPath value) { - return reference - .add(value) - .then((ref) => ExplicitPathDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$ExplicitPathCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< - ExplicitPath, ExplicitPathDocumentSnapshot> { - factory ExplicitPathDocumentReference( - DocumentReference reference) = - _$ExplicitPathDocumentReference; - - DocumentReference get reference; - - /// A reference to the [ExplicitPathCollectionReference] containing this document. - ExplicitPathCollectionReference get parent { - return _$ExplicitPathCollectionReference(reference.firestore); - } - - late final ExplicitSubPathCollectionReference sub = - _$ExplicitSubPathCollectionReference( - reference, - ); - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - ExplicitPath model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - ExplicitPath model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - ExplicitPath model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - ExplicitPath, - ExplicitPathDocumentSnapshot> implements ExplicitPathDocumentReference { - _$ExplicitPathDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [ExplicitPathCollectionReference] containing this document. - ExplicitPathCollectionReference get parent { - return _$ExplicitPathCollectionReference(reference.firestore); - } - - late final ExplicitSubPathCollectionReference sub = - _$ExplicitSubPathCollectionReference( - reference, - ); - - @override - Stream snapshots() { - return reference.snapshots().map(ExplicitPathDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(ExplicitPathDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(ExplicitPathDocumentSnapshot._); - } - - Future set( - ExplicitPath model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$ExplicitPathFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - ExplicitPath model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$ExplicitPathFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - ExplicitPath model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$ExplicitPathFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class ExplicitPathQuery - implements QueryReference { - @override - ExplicitPathQuery limit(int limit); - - @override - ExplicitPathQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - ExplicitPathQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ExplicitPathQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ExplicitPathQuery whereValue({ - num? isEqualTo, - num? isNotEqualTo, - num? isLessThan, - num? isLessThanOrEqualTo, - num? isGreaterThan, - num? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - ExplicitPathQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - ExplicitPathDocumentSnapshot? startAtDocument, - ExplicitPathDocumentSnapshot? endAtDocument, - ExplicitPathDocumentSnapshot? endBeforeDocument, - ExplicitPathDocumentSnapshot? startAfterDocument, - }); - - ExplicitPathQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - ExplicitPathDocumentSnapshot? startAtDocument, - ExplicitPathDocumentSnapshot? endAtDocument, - ExplicitPathDocumentSnapshot? endBeforeDocument, - ExplicitPathDocumentSnapshot? startAfterDocument, - }); - - ExplicitPathQuery orderByValue({ - bool descending = false, - num startAt, - num startAfter, - num endAt, - num endBefore, - ExplicitPathDocumentSnapshot? startAtDocument, - ExplicitPathDocumentSnapshot? endAtDocument, - ExplicitPathDocumentSnapshot? endBeforeDocument, - ExplicitPathDocumentSnapshot? startAfterDocument, - }); -} - -class _$ExplicitPathQuery - extends QueryReference - implements ExplicitPathQuery { - _$ExplicitPathQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(ExplicitPathQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(ExplicitPathQuerySnapshot._fromQuerySnapshot); - } - - @override - ExplicitPathQuery limit(int limit) { - return _$ExplicitPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitPathQuery limitToLast(int limit) { - return _$ExplicitPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitPathQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ExplicitPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitPathQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ExplicitPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitPathQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ExplicitPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$ExplicitPathFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$ExplicitPathPerFieldToJson.value(isEqualTo as num) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$ExplicitPathPerFieldToJson.value(isNotEqualTo as num) - : null, - isLessThan: isLessThan != null - ? _$ExplicitPathPerFieldToJson.value(isLessThan as num) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$ExplicitPathPerFieldToJson.value(isLessThanOrEqualTo as num) - : null, - isGreaterThan: isGreaterThan != null - ? _$ExplicitPathPerFieldToJson.value(isGreaterThan as num) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$ExplicitPathPerFieldToJson.value(isGreaterThanOrEqualTo as num) - : null, - whereIn: whereIn?.map((e) => _$ExplicitPathPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$ExplicitPathPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitPathQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ExplicitPathDocumentSnapshot? startAtDocument, - ExplicitPathDocumentSnapshot? endAtDocument, - ExplicitPathDocumentSnapshot? endBeforeDocument, - ExplicitPathDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ExplicitPathQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ExplicitPathQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ExplicitPathDocumentSnapshot? startAtDocument, - ExplicitPathDocumentSnapshot? endAtDocument, - ExplicitPathDocumentSnapshot? endBeforeDocument, - ExplicitPathDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ExplicitPathQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ExplicitPathQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ExplicitPathDocumentSnapshot? startAtDocument, - ExplicitPathDocumentSnapshot? endAtDocument, - ExplicitPathDocumentSnapshot? endBeforeDocument, - ExplicitPathDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$ExplicitPathFieldMap['value']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ExplicitPathQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$ExplicitPathQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class ExplicitPathDocumentSnapshot - extends FirestoreDocumentSnapshot { - ExplicitPathDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - ExplicitPathDocumentReference get reference { - return ExplicitPathDocumentReference( - snapshot.reference, - ); - } - - @override - final ExplicitPath? data; -} - -class ExplicitPathQuerySnapshot extends FirestoreQuerySnapshot { - ExplicitPathQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory ExplicitPathQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(ExplicitPathQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ExplicitPathDocumentSnapshot._, - ); - }).toList(); - - return ExplicitPathQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - ExplicitPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class ExplicitPathQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements ExplicitPathDocumentSnapshot { - ExplicitPathQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final ExplicitPath data; - - @override - ExplicitPathDocumentReference get reference { - return ExplicitPathDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class ExplicitSubPathCollectionReference - implements - ExplicitSubPathQuery, - FirestoreCollectionReference { - factory ExplicitSubPathCollectionReference( - DocumentReference parent, - ) = _$ExplicitSubPathCollectionReference; - - static ExplicitSubPath fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return ExplicitSubPath.fromJson(snapshot.data()!); - } - - static Map toFirestore( - ExplicitSubPath value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - /// A reference to the containing [ExplicitPathDocumentReference] if this is a subcollection. - ExplicitPathDocumentReference get parent; - - @override - ExplicitSubPathDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(ExplicitSubPath value); -} - -class _$ExplicitSubPathCollectionReference extends _$ExplicitSubPathQuery - implements ExplicitSubPathCollectionReference { - factory _$ExplicitSubPathCollectionReference( - DocumentReference parent, - ) { - return _$ExplicitSubPathCollectionReference._( - ExplicitPathDocumentReference(parent), - parent.collection('sub').withConverter( - fromFirestore: ExplicitSubPathCollectionReference.fromFirestore, - toFirestore: ExplicitSubPathCollectionReference.toFirestore, - ), - ); - } - - _$ExplicitSubPathCollectionReference._( - this.parent, - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - @override - final ExplicitPathDocumentReference parent; - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - ExplicitSubPathDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return ExplicitSubPathDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(ExplicitSubPath value) { - return reference - .add(value) - .then((ref) => ExplicitSubPathDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$ExplicitSubPathCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class ExplicitSubPathDocumentReference - extends FirestoreDocumentReference { - factory ExplicitSubPathDocumentReference( - DocumentReference reference) = - _$ExplicitSubPathDocumentReference; - - DocumentReference get reference; - - /// A reference to the [ExplicitSubPathCollectionReference] containing this document. - ExplicitSubPathCollectionReference get parent { - return _$ExplicitSubPathCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: ExplicitPathCollectionReference.fromFirestore, - toFirestore: ExplicitPathCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - ExplicitSubPath model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - ExplicitSubPath model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - ExplicitSubPath model, { - SetOptions? options, - FieldValue valueFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - 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< - ExplicitSubPath, ExplicitSubPathDocumentSnapshot> - implements ExplicitSubPathDocumentReference { - _$ExplicitSubPathDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [ExplicitSubPathCollectionReference] containing this document. - ExplicitSubPathCollectionReference get parent { - return _$ExplicitSubPathCollectionReference( - reference.parent.parent!.withConverter( - fromFirestore: ExplicitPathCollectionReference.fromFirestore, - toFirestore: ExplicitPathCollectionReference.toFirestore, - ), - ); - } - - @override - Stream snapshots() { - return reference.snapshots().map(ExplicitSubPathDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(ExplicitSubPathDocumentSnapshot._); - } - - @override - Future transactionGet( - Transaction transaction) { - return transaction.get(reference).then(ExplicitSubPathDocumentSnapshot._); - } - - Future set( - ExplicitSubPath model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) async { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$ExplicitSubPathFieldMap['value']!: valueFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - ExplicitSubPath model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$ExplicitSubPathFieldMap['value']!: valueFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - ExplicitSubPath model, { - SetOptions? options, - FieldValue? valueFieldValue, - }) { - final json = { - ...model.toJson(), - if (valueFieldValue != null) - _$ExplicitSubPathFieldMap['value']!: valueFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? value = _sentinel, - FieldValue? valueFieldValue, - }) async { - 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, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - 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, - }; - - 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 && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class ExplicitSubPathQuery - implements QueryReference { - @override - ExplicitSubPathQuery limit(int limit); - - @override - ExplicitSubPathQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - ExplicitSubPathQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ExplicitSubPathQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - ExplicitSubPathQuery whereValue({ - num? isEqualTo, - num? isNotEqualTo, - num? isLessThan, - num? isLessThanOrEqualTo, - num? isGreaterThan, - num? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - ExplicitSubPathQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - ExplicitSubPathDocumentSnapshot? startAtDocument, - ExplicitSubPathDocumentSnapshot? endAtDocument, - ExplicitSubPathDocumentSnapshot? endBeforeDocument, - ExplicitSubPathDocumentSnapshot? startAfterDocument, - }); - - ExplicitSubPathQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - ExplicitSubPathDocumentSnapshot? startAtDocument, - ExplicitSubPathDocumentSnapshot? endAtDocument, - ExplicitSubPathDocumentSnapshot? endBeforeDocument, - ExplicitSubPathDocumentSnapshot? startAfterDocument, - }); - - ExplicitSubPathQuery orderByValue({ - bool descending = false, - num startAt, - num startAfter, - num endAt, - num endBefore, - ExplicitSubPathDocumentSnapshot? startAtDocument, - ExplicitSubPathDocumentSnapshot? endAtDocument, - ExplicitSubPathDocumentSnapshot? endBeforeDocument, - ExplicitSubPathDocumentSnapshot? startAfterDocument, - }); -} - -class _$ExplicitSubPathQuery - extends QueryReference - implements ExplicitSubPathQuery { - _$ExplicitSubPathQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(ExplicitSubPathQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(ExplicitSubPathQuerySnapshot._fromQuerySnapshot); - } - - @override - ExplicitSubPathQuery limit(int limit) { - return _$ExplicitSubPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitSubPathQuery limitToLast(int limit) { - return _$ExplicitSubPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitSubPathQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ExplicitSubPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitSubPathQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ExplicitSubPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitSubPathQuery whereValue({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$ExplicitSubPathQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$ExplicitSubPathFieldMap['value']!, - isEqualTo: isEqualTo != _sentinel - ? _$ExplicitSubPathPerFieldToJson.value(isEqualTo as num) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$ExplicitSubPathPerFieldToJson.value(isNotEqualTo as num) - : null, - isLessThan: isLessThan != null - ? _$ExplicitSubPathPerFieldToJson.value(isLessThan as num) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$ExplicitSubPathPerFieldToJson.value(isLessThanOrEqualTo as num) - : null, - isGreaterThan: isGreaterThan != null - ? _$ExplicitSubPathPerFieldToJson.value(isGreaterThan as num) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$ExplicitSubPathPerFieldToJson - .value(isGreaterThanOrEqualTo as num) - : null, - whereIn: whereIn?.map((e) => _$ExplicitSubPathPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$ExplicitSubPathPerFieldToJson.value(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - ExplicitSubPathQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ExplicitSubPathDocumentSnapshot? startAtDocument, - ExplicitSubPathDocumentSnapshot? endAtDocument, - ExplicitSubPathDocumentSnapshot? endBeforeDocument, - ExplicitSubPathDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ExplicitSubPathQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ExplicitSubPathQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ExplicitSubPathDocumentSnapshot? startAtDocument, - ExplicitSubPathDocumentSnapshot? endAtDocument, - ExplicitSubPathDocumentSnapshot? endBeforeDocument, - ExplicitSubPathDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ExplicitSubPathQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - ExplicitSubPathQuery orderByValue({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - ExplicitSubPathDocumentSnapshot? startAtDocument, - ExplicitSubPathDocumentSnapshot? endAtDocument, - ExplicitSubPathDocumentSnapshot? endBeforeDocument, - ExplicitSubPathDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$ExplicitSubPathFieldMap['value']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$ExplicitSubPathQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$ExplicitSubPathQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class ExplicitSubPathDocumentSnapshot - extends FirestoreDocumentSnapshot { - ExplicitSubPathDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - ExplicitSubPathDocumentReference get reference { - return ExplicitSubPathDocumentReference( - snapshot.reference, - ); - } - - @override - final ExplicitSubPath? data; -} - -class ExplicitSubPathQuerySnapshot extends FirestoreQuerySnapshot< - ExplicitSubPath, ExplicitSubPathQueryDocumentSnapshot> { - ExplicitSubPathQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory ExplicitSubPathQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = - snapshot.docs.map(ExplicitSubPathQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ExplicitSubPathDocumentSnapshot._, - ); - }).toList(); - - return ExplicitSubPathQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - ExplicitSubPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> - docChanges; -} - -class ExplicitSubPathQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements ExplicitSubPathDocumentSnapshot { - ExplicitSubPathQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final ExplicitSubPath data; - - @override - ExplicitSubPathDocumentReference get reference { - return ExplicitSubPathDocumentReference(snapshot.reference); - } -} - -/// A collection reference object can be used for adding documents, -/// getting document references, and querying for documents -/// (using the methods inherited from Query). -abstract class SubClassCollectionReference - implements - SubClassQuery, - FirestoreCollectionReference { - factory SubClassCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$SubClassCollectionReference; - - static SubClass fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return SubClass.fromJson(snapshot.data()!); - } - - static Map toFirestore( - SubClass value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - SubClassDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(SubClass value); -} - -class _$SubClassCollectionReference extends _$SubClassQuery - implements SubClassCollectionReference { - factory _$SubClassCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$SubClassCollectionReference._( - firestore.collection('root').withConverter( - fromFirestore: SubClassCollectionReference.fromFirestore, - toFirestore: SubClassCollectionReference.toFirestore, - ), - ); - } - - _$SubClassCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - SubClassDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return SubClassDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(SubClass value) { - return reference.add(value).then((ref) => SubClassDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$SubClassCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class SubClassDocumentReference - extends FirestoreDocumentReference { - factory SubClassDocumentReference(DocumentReference reference) = - _$SubClassDocumentReference; - - DocumentReference get reference; - - /// A reference to the [SubClassCollectionReference] containing this document. - SubClassCollectionReference get parent { - return _$SubClassCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// Sets data on the document, overwriting any existing data. If the document - /// does not yet exist, it will be created. - /// - /// If [SetOptions] are provided, the data can be merged into an existing - /// document instead of overwriting. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - Future set( - SubClass model, { - SetOptions? options, - FieldValue instanceGetterFieldValue, - }); - - /// Writes to the document using the transaction API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void transactionSet( - Transaction transaction, - SubClass model, { - SetOptions? options, - FieldValue instanceGetterFieldValue, - }); - - /// Writes to the document using the batch API. - /// - /// If the document does not exist yet, it will be created. If you pass - /// [SetOptions], the provided data can be merged into the existing document. - /// - /// Any [FieldValue]s provided will replace the corresponding fields in the - /// [model] during serialization. - void batchSet( - WriteBatch batch, - SubClass model, { - SetOptions? options, - FieldValue instanceGetterFieldValue, - }); - - /// Updates data on the document. Data will be merged with any existing - /// document data. - /// - /// If no document exists yet, the update will fail. - Future update({ - int instanceGetter, - FieldValue instanceGetterFieldValue, - }); - - /// Updates fields in the current document using the transaction API. - /// - /// The update will fail if applied to a document that does not exist. - void transactionUpdate( - Transaction transaction, { - int instanceGetter, - FieldValue instanceGetterFieldValue, - }); - - /// 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 instanceGetter, - FieldValue instanceGetterFieldValue, - }); -} - -class _$SubClassDocumentReference - extends FirestoreDocumentReference - implements SubClassDocumentReference { - _$SubClassDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [SubClassCollectionReference] containing this document. - SubClassCollectionReference get parent { - return _$SubClassCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(SubClassDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(SubClassDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(SubClassDocumentSnapshot._); - } - - Future set( - SubClass model, { - SetOptions? options, - FieldValue? instanceGetterFieldValue, - }) async { - final json = { - ...model.toJson(), - if (instanceGetterFieldValue != null) - _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, - }; - - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); - return castedReference.set(json, options); - } - - void transactionSet( - Transaction transaction, - SubClass model, { - SetOptions? options, - FieldValue? instanceGetterFieldValue, - }) { - final json = { - ...model.toJson(), - if (instanceGetterFieldValue != null) - _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, - }; - - transaction.set(reference, json, options); - } - - void batchSet( - WriteBatch batch, - SubClass model, { - SetOptions? options, - FieldValue? instanceGetterFieldValue, - }) { - final json = { - ...model.toJson(), - if (instanceGetterFieldValue != null) - _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, - }; - - batch.set(reference, json, options); - } - - Future update({ - Object? instanceGetter = _sentinel, - FieldValue? instanceGetterFieldValue, - }) async { - assert( - instanceGetter == _sentinel || instanceGetterFieldValue == null, - "Cannot specify both instanceGetter and instanceGetterFieldValue", - ); - final json = { - if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), - if (instanceGetterFieldValue != null) - _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - Object? instanceGetter = _sentinel, - FieldValue? instanceGetterFieldValue, - }) { - assert( - instanceGetter == _sentinel || instanceGetterFieldValue == null, - "Cannot specify both instanceGetter and instanceGetterFieldValue", - ); - final json = { - if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), - if (instanceGetterFieldValue != null) - _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, - }; - - transaction.update(reference, json); - } - - void batchUpdate( - WriteBatch batch, { - Object? instanceGetter = _sentinel, - FieldValue? instanceGetterFieldValue, - }) { - assert( - instanceGetter == _sentinel || instanceGetterFieldValue == null, - "Cannot specify both instanceGetter and instanceGetterFieldValue", - ); - final json = { - if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), - if (instanceGetterFieldValue != null) - _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, - }; - - batch.update(reference, json); - } - - @override - bool operator ==(Object other) { - return other is SubClassDocumentReference && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class SubClassQuery - implements QueryReference { - @override - SubClassQuery limit(int limit); - - @override - SubClassQuery limitToLast(int limit); - - /// Perform a where query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of where queries: - /// - /// **AVOID**: - /// ```dart - /// collection.whereFieldPath(FieldPath.fromString('title'), isEqualTo: 'title'); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.whereTitle(isEqualTo: 'title'); - /// ``` - SubClassQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - SubClassQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - SubClassQuery whereInstanceGetter({ - int? isEqualTo, - int? isNotEqualTo, - int? isLessThan, - int? isLessThanOrEqualTo, - int? isGreaterThan, - int? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - /// Perform an order query based on a [FieldPath]. - /// - /// This method is considered unsafe as it does check that the field path - /// maps to a valid property or that parameters such as [isEqualTo] receive - /// a value of the correct type. - /// - /// If possible, instead use the more explicit variant of order queries: - /// - /// **AVOID**: - /// ```dart - /// collection.orderByFieldPath( - /// FieldPath.fromString('title'), - /// startAt: 'title', - /// ); - /// ``` - /// - /// **PREFER**: - /// ```dart - /// collection.orderByTitle(startAt: 'title'); - /// ``` - SubClassQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object startAt, - Object startAfter, - Object endAt, - Object endBefore, - SubClassDocumentSnapshot? startAtDocument, - SubClassDocumentSnapshot? endAtDocument, - SubClassDocumentSnapshot? endBeforeDocument, - SubClassDocumentSnapshot? startAfterDocument, - }); - - SubClassQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - SubClassDocumentSnapshot? startAtDocument, - SubClassDocumentSnapshot? endAtDocument, - SubClassDocumentSnapshot? endBeforeDocument, - SubClassDocumentSnapshot? startAfterDocument, - }); - - SubClassQuery orderByInstanceGetter({ - bool descending = false, - int startAt, - int startAfter, - int endAt, - int endBefore, - SubClassDocumentSnapshot? startAtDocument, - SubClassDocumentSnapshot? endAtDocument, - SubClassDocumentSnapshot? endBeforeDocument, - SubClassDocumentSnapshot? startAfterDocument, - }); -} - -class _$SubClassQuery extends QueryReference - implements SubClassQuery { - _$SubClassQuery( - this._collection, { - required Query $referenceWithoutCursor, - $QueryCursor $queryCursor = const $QueryCursor(), - }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); - - final CollectionReference _collection; - - @override - Stream snapshots([SnapshotOptions? options]) { - return reference.snapshots().map(SubClassQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference - .get(options) - .then(SubClassQuerySnapshot._fromQuerySnapshot); - } - - @override - SubClassQuery limit(int limit) { - return _$SubClassQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - SubClassQuery limitToLast(int limit) { - return _$SubClassQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - @override - SubClassQuery whereFieldPath( - Object fieldPath, { - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$SubClassQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - SubClassQuery whereDocumentId({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$SubClassQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo != _sentinel ? isEqualTo : null, - isNotEqualTo: isNotEqualTo != _sentinel ? isNotEqualTo : null, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - SubClassQuery whereInstanceGetter({ - Object? isEqualTo = _sentinel, - Object? isNotEqualTo = _sentinel, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$SubClassQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$SubClassFieldMap['instanceGetter']!, - isEqualTo: isEqualTo != _sentinel - ? _$SubClassPerFieldToJson.instanceGetter(isEqualTo as int) - : null, - isNotEqualTo: isNotEqualTo != _sentinel - ? _$SubClassPerFieldToJson.instanceGetter(isNotEqualTo as int) - : null, - isLessThan: isLessThan != null - ? _$SubClassPerFieldToJson.instanceGetter(isLessThan as int) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$SubClassPerFieldToJson - .instanceGetter(isLessThanOrEqualTo as int) - : null, - isGreaterThan: isGreaterThan != null - ? _$SubClassPerFieldToJson.instanceGetter(isGreaterThan as int) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$SubClassPerFieldToJson - .instanceGetter(isGreaterThanOrEqualTo as int) - : null, - whereIn: - whereIn?.map((e) => _$SubClassPerFieldToJson.instanceGetter(e)), - whereNotIn: - whereNotIn?.map((e) => _$SubClassPerFieldToJson.instanceGetter(e)), - isNull: isNull ?? - (isEqualTo == null ? false : null) ?? - (isNotEqualTo == null ? true : null), - ), - $queryCursor: $queryCursor, - ); - } - - @override - SubClassQuery orderByFieldPath( - Object fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - SubClassDocumentSnapshot? startAtDocument, - SubClassDocumentSnapshot? endAtDocument, - SubClassDocumentSnapshot? endBeforeDocument, - SubClassDocumentSnapshot? startAfterDocument, - }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$SubClassQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - SubClassQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - SubClassDocumentSnapshot? startAtDocument, - SubClassDocumentSnapshot? endAtDocument, - SubClassDocumentSnapshot? endBeforeDocument, - SubClassDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$SubClassQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - SubClassQuery orderByInstanceGetter({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - SubClassDocumentSnapshot? startAtDocument, - SubClassDocumentSnapshot? endAtDocument, - SubClassDocumentSnapshot? endBeforeDocument, - SubClassDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$SubClassFieldMap['instanceGetter']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$SubClassQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$SubClassQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class SubClassDocumentSnapshot extends FirestoreDocumentSnapshot { - SubClassDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - SubClassDocumentReference get reference { - return SubClassDocumentReference( - snapshot.reference, - ); - } - - @override - final SubClass? data; -} - -class SubClassQuerySnapshot - extends FirestoreQuerySnapshot { - SubClassQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory SubClassQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(SubClassQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - SubClassDocumentSnapshot._, - ); - }).toList(); - - return SubClassQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange - _decodeDocumentChange( - DocumentChange docChange, - SubClassDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, - ) { - return FirestoreDocumentChange( - type: docChange.type, - oldIndex: docChange.oldIndex, - newIndex: docChange.newIndex, - doc: decodeDoc(docChange.doc), - ); - } - - final QuerySnapshot snapshot; - - @override - final List docs; - - @override - final List> docChanges; -} - -class SubClassQueryDocumentSnapshot - extends FirestoreQueryDocumentSnapshot - implements SubClassDocumentSnapshot { - SubClassQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final SubClass data; - - @override - SubClassDocumentReference get reference { - return SubClassDocumentReference(snapshot.reference); - } -} - -// ************************************************************************** -// ValidatorGenerator -// ************************************************************************** - -void _$assertMinValidation(MinValidation instance) { - const Min(0).validate(instance.intNbr, 'intNbr'); - const Max(42).validate(instance.intNbr, 'intNbr'); - const Min(10).validate(instance.doubleNbr, 'doubleNbr'); - const Min(-10).validate(instance.numNbr, 'numNbr'); -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** IgnoredGetter _$IgnoredGetterFromJson(Map json) => - IgnoredGetter( - (json['value'] as num).toInt(), - ); + IgnoredGetter((json['value'] as num).toInt()); const _$IgnoredGetterFieldMap = { 'value': 'value', @@ -15535,18 +23,12 @@ abstract class _$IgnoredGetterPerFieldToJson { } Map _$IgnoredGetterToJson(IgnoredGetter instance) => - { - 'value': instance.value, - 'count3': instance.count3, - }; + {'value': instance.value, 'count3': instance.count3}; -Model _$ModelFromJson(Map json) => Model( - json['value'] as String, - ); +Model _$ModelFromJson(Map json) => + Model(json['value'] as String); -const _$ModelFieldMap = { - 'value': 'value', -}; +const _$ModelFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$ModelPerFieldToJson { @@ -15555,38 +37,39 @@ abstract class _$ModelPerFieldToJson { } Map _$ModelToJson(Model instance) => { - 'value': instance.value, - }; + 'value': instance.value, +}; Nested _$NestedFromJson(Map json) => Nested( - value: json['value'] == null - ? null - : Nested.fromJson(json['value'] as Map), - simple: (json['simple'] as num?)?.toInt(), - valueList: (json['valueList'] as List?) - ?.map((e) => Nested.fromJson(e as Map)) - .toList(), - boolList: - (json['boolList'] as List?)?.map((e) => e as bool).toList(), - stringList: (json['stringList'] as List?) - ?.map((e) => e as String) - .toList(), - numList: - (json['numList'] as List?)?.map((e) => e as num).toList(), - objectList: json['objectList'] as List?, - dynamicList: json['dynamicList'] as List?, - boolSet: - (json['boolSet'] as List?)?.map((e) => e as bool).toSet(), - enumValue: $enumDecode(_$TestEnumEnumMap, json['enumValue']), - nullableEnumValue: - $enumDecodeNullable(_$TestEnumEnumMap, json['nullableEnumValue']), - enumList: (json['enumList'] as List) - .map((e) => $enumDecode(_$TestEnumEnumMap, e)) - .toList(), - nullableEnumList: (json['nullableEnumList'] as List?) - ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) - .toList(), - ); + value: json['value'] == null + ? null + : Nested.fromJson(json['value'] as Map), + simple: (json['simple'] as num?)?.toInt(), + valueList: (json['valueList'] as List?) + ?.map((e) => Nested.fromJson(e as Map)) + .toList(), + boolList: (json['boolList'] as List?) + ?.map((e) => e as bool) + .toList(), + stringList: (json['stringList'] as List?) + ?.map((e) => e as String) + .toList(), + numList: (json['numList'] as List?)?.map((e) => e as num).toList(), + objectList: json['objectList'] as List?, + dynamicList: json['dynamicList'] as List?, + boolSet: (json['boolSet'] as List?)?.map((e) => e as bool).toSet(), + enumValue: $enumDecode(_$TestEnumEnumMap, json['enumValue']), + nullableEnumValue: $enumDecodeNullable( + _$TestEnumEnumMap, + json['nullableEnumValue'], + ), + enumList: (json['enumList'] as List) + .map((e) => $enumDecode(_$TestEnumEnumMap, e)) + .toList(), + nullableEnumList: (json['nullableEnumList'] as List?) + ?.map((e) => $enumDecode(_$TestEnumEnumMap, e)) + .toList(), +); const _$NestedFieldMap = { 'value': 'value', @@ -15638,21 +121,22 @@ abstract class _$NestedPerFieldToJson { } Map _$NestedToJson(Nested instance) => { - 'value': instance.value, - 'simple': instance.simple, - 'valueList': instance.valueList, - 'boolList': instance.boolList, - 'stringList': instance.stringList, - 'numList': instance.numList, - 'objectList': instance.objectList, - 'dynamicList': instance.dynamicList, - 'boolSet': instance.boolSet?.toList(), - 'enumValue': _$TestEnumEnumMap[instance.enumValue]!, - 'nullableEnumValue': _$TestEnumEnumMap[instance.nullableEnumValue], - 'enumList': instance.enumList.map((e) => _$TestEnumEnumMap[e]!).toList(), - 'nullableEnumList': - instance.nullableEnumList?.map((e) => _$TestEnumEnumMap[e]!).toList(), - }; + 'value': instance.value, + 'simple': instance.simple, + 'valueList': instance.valueList, + 'boolList': instance.boolList, + 'stringList': instance.stringList, + 'numList': instance.numList, + 'objectList': instance.objectList, + 'dynamicList': instance.dynamicList, + 'boolSet': instance.boolSet?.toList(), + 'enumValue': _$TestEnumEnumMap[instance.enumValue]!, + 'nullableEnumValue': _$TestEnumEnumMap[instance.nullableEnumValue], + 'enumList': instance.enumList.map((e) => _$TestEnumEnumMap[e]!).toList(), + 'nullableEnumList': instance.nullableEnumList + ?.map((e) => _$TestEnumEnumMap[e]!) + .toList(), +}; const _$TestEnumEnumMap = { TestEnum.one: 'one', @@ -15700,10 +184,8 @@ Map _$MinValidationToJson(MinValidation instance) => 'numNbr': instance.numNbr, }; -Root _$RootFromJson(Map json) => Root( - json['nonNullable'] as String, - (json['nullable'] as num?)?.toInt(), - ); +Root _$RootFromJson(Map json) => + Root(json['nonNullable'] as String, (json['nullable'] as num?)?.toInt()); const _$RootFieldMap = { 'nonNullable': 'nonNullable', @@ -15719,17 +201,14 @@ abstract class _$RootPerFieldToJson { } Map _$RootToJson(Root instance) => { - 'nonNullable': instance.nonNullable, - 'nullable': instance.nullable, - }; + 'nonNullable': instance.nonNullable, + 'nullable': instance.nullable, +}; -OptionalJson _$OptionalJsonFromJson(Map json) => OptionalJson( - (json['value'] as num).toInt(), - ); +OptionalJson _$OptionalJsonFromJson(Map json) => + OptionalJson((json['value'] as num).toInt()); -const _$OptionalJsonFieldMap = { - 'value': 'value', -}; +const _$OptionalJsonFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$OptionalJsonPerFieldToJson { @@ -15738,17 +217,12 @@ abstract class _$OptionalJsonPerFieldToJson { } Map _$OptionalJsonToJson(OptionalJson instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; -MixedJson _$MixedJsonFromJson(Map json) => MixedJson( - (json['value'] as num).toInt(), - ); +MixedJson _$MixedJsonFromJson(Map json) => + MixedJson((json['value'] as num).toInt()); -const _$MixedJsonFieldMap = { - 'value': 'value', -}; +const _$MixedJsonFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$MixedJsonPerFieldToJson { @@ -15757,13 +231,11 @@ abstract class _$MixedJsonPerFieldToJson { } Map _$MixedJsonToJson(MixedJson instance) => { - 'value': instance.value, - }; + 'value': instance.value, +}; -Sub _$SubFromJson(Map json) => Sub( - json['nonNullable'] as String, - (json['nullable'] as num?)?.toInt(), - ); +Sub _$SubFromJson(Map json) => + Sub(json['nonNullable'] as String, (json['nullable'] as num?)?.toInt()); const _$SubFieldMap = { 'nonNullable': 'nonNullable', @@ -15779,18 +251,14 @@ abstract class _$SubPerFieldToJson { } Map _$SubToJson(Sub instance) => { - 'nonNullable': instance.nonNullable, - 'nullable': instance.nullable, - }; + 'nonNullable': instance.nonNullable, + 'nullable': instance.nullable, +}; CustomSubName _$CustomSubNameFromJson(Map json) => - CustomSubName( - json['value'] as num, - ); + CustomSubName(json['value'] as num); -const _$CustomSubNameFieldMap = { - 'value': 'value', -}; +const _$CustomSubNameFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$CustomSubNamePerFieldToJson { @@ -15799,17 +267,12 @@ abstract class _$CustomSubNamePerFieldToJson { } Map _$CustomSubNameToJson(CustomSubName instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; -AsCamelCase _$AsCamelCaseFromJson(Map json) => AsCamelCase( - json['value'] as num, - ); +AsCamelCase _$AsCamelCaseFromJson(Map json) => + AsCamelCase(json['value'] as num); -const _$AsCamelCaseFieldMap = { - 'value': 'value', -}; +const _$AsCamelCaseFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$AsCamelCasePerFieldToJson { @@ -15818,18 +281,12 @@ abstract class _$AsCamelCasePerFieldToJson { } Map _$AsCamelCaseToJson(AsCamelCase instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; CustomClassPrefix _$CustomClassPrefixFromJson(Map json) => - CustomClassPrefix( - json['value'] as num, - ); + CustomClassPrefix(json['value'] as num); -const _$CustomClassPrefixFieldMap = { - 'value': 'value', -}; +const _$CustomClassPrefixFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$CustomClassPrefixPerFieldToJson { @@ -15838,17 +295,12 @@ abstract class _$CustomClassPrefixPerFieldToJson { } Map _$CustomClassPrefixToJson(CustomClassPrefix instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; -ExplicitPath _$ExplicitPathFromJson(Map json) => ExplicitPath( - json['value'] as num, - ); +ExplicitPath _$ExplicitPathFromJson(Map json) => + ExplicitPath(json['value'] as num); -const _$ExplicitPathFieldMap = { - 'value': 'value', -}; +const _$ExplicitPathFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$ExplicitPathPerFieldToJson { @@ -15857,18 +309,12 @@ abstract class _$ExplicitPathPerFieldToJson { } Map _$ExplicitPathToJson(ExplicitPath instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; ExplicitSubPath _$ExplicitSubPathFromJson(Map json) => - ExplicitSubPath( - json['value'] as num, - ); + ExplicitSubPath(json['value'] as num); -const _$ExplicitSubPathFieldMap = { - 'value': 'value', -}; +const _$ExplicitSubPathFieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$ExplicitSubPathPerFieldToJson { @@ -15877,17 +323,12 @@ abstract class _$ExplicitSubPathPerFieldToJson { } Map _$ExplicitSubPathToJson(ExplicitSubPath instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; -SubClass _$SubClassFromJson(Map json) => SubClass( - (json['instanceGetter'] as num).toInt(), - ); +SubClass _$SubClassFromJson(Map json) => + SubClass((json['instanceGetter'] as num).toInt()); -const _$SubClassFieldMap = { - 'instanceGetter': 'instanceGetter', -}; +const _$SubClassFieldMap = {'instanceGetter': 'instanceGetter'}; // ignore: unused_element abstract class _$SubClassPerFieldToJson { @@ -15896,5 +337,5 @@ abstract class _$SubClassPerFieldToJson { } Map _$SubClassToJson(SubClass instance) => { - 'instanceGetter': instance.instanceGetter, - }; + 'instanceGetter': instance.instanceGetter, +}; diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml index b3d3235..5394c9b 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/pubspec.yaml @@ -2,29 +2,35 @@ name: cloud_firestore_odm_generator_integration_test publish_to: none environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.9.2 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 - cloud_firestore_odm: ^1.0.0-dev.85 + cloud_firestore: ^6.0.0 + cloud_firestore_odm: ^2.0.0 flutter: sdk: flutter - freezed_annotation: ^2.2.0 - json_annotation: ^4.8.1 + flutter_riverpod: 3.0.0 + freezed_annotation: ^3.1.0 + json_annotation: ^4.9.0 meta: ^1.12.0 + riverpod_annotation: 3.0.0 dev_dependencies: - build_runner: ^2.4.2 + build_runner: ^2.8.0 cloud_firestore_odm_generator: path: ../ + firebase_core_platform_interface: ^6.0.0 flutter_test: sdk: flutter - freezed: ^2.3.2 - json_serializable: '>=6.6.1 <7.0.0' + freezed: ^3.2.0 + json_serializable: ^6.11.0 + riverpod_generator: 3.0.0 + test: ^1.26.3 dependency_overrides: cloud_firestore_odm: path: ../../cloud_firestore_odm + test_api: ^0.7.7 flutter: uses-material-design: false diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/collection_test.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/collection_test.dart index fb768c9..077a75f 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/collection_test.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/collection_test.dart @@ -2,51 +2,52 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +import 'package:cloud_firestore_odm_generator_integration_test/freezed.dart'; import 'package:cloud_firestore_odm_generator_integration_test/simple.dart'; import 'package:flutter_test/flutter_test.dart'; import 'setup_firestore_mock.dart'; void main() { - setUpAll(setupCloudFirestoreMocks); + setUpAll(setupFirestoreMocks); test('can specify @Collection on the model itself', () { - expect( - ModelCollectionReference().path, - 'root', - ); + expect(ModelCollectionReference().path, 'root'); }); group('orderBy', () { testWidgets('applies `descending`', (tester) async { - expect( - rootRef.orderByNullable(descending: true), - rootRef.orderByNullable(descending: true), - ); - expect( - rootRef.orderByNullable(descending: true), - isNot(rootRef.orderByNullable()), - ); - expect( - rootRef.orderByNullable(), - rootRef.orderByNullable(), - ); + expect(rootRef.orderByNullable(descending: true), rootRef.orderByNullable(descending: true)); + expect(rootRef.orderByNullable(descending: true), isNot(rootRef.orderByNullable())); + expect(rootRef.orderByNullable(), rootRef.orderByNullable()); }); }); group('doc', () { - test('asserts that the path does not point to a separate collection', - () async { + test('asserts that the path does not point to a separate collection', () async { rootRef.doc('42'); - expect( - () => rootRef.doc('42/123'), - throwsAssertionError, - ); - expect( - () => rootRef.doc('42/123/456'), - throwsAssertionError, - ); + expect(() => rootRef.doc('42/123'), throwsAssertionError); + expect(() => rootRef.doc('42/123/456'), throwsAssertionError); + }); + }); + + /// test freezed mixed mode classes + group('freezed mixed mode classes', () { + test('test freezed simple classes', () { + const simpleFreezed = SimpleFreezed(a: 42); + expect(simpleFreezed.toJson(), {'a': 42}); + + final simpleFreezedFromJson = SimpleFreezed.fromJson({'a': 42}); + expect(simpleFreezedFromJson.a, 42); + }); + + test('test freezed factory classes', () { + final publicRedirected = PublicRedirected(value: 'test'); + expect(publicRedirected.toJson(), {'value': 'test'}); + + final publicRedirectedFromJson = PublicRedirected.fromJson({'value': 'test'}); + expect(publicRedirectedFromJson.value, 'test'); }); }); } diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/riverpod_integration_test.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/riverpod_integration_test.dart new file mode 100644 index 0000000..9800e32 --- /dev/null +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/riverpod_integration_test.dart @@ -0,0 +1,155 @@ +// Copyright 2022, the Chromium project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:cloud_firestore_odm_generator_integration_test/riverpod_integration.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'setup_firestore_mock.dart'; + +void main() { + setUpAll(setupFirestoreMocks); + + group('Riverpod Integration Tests', () { + test('UserProfile model can be created and serialized', () { + const userProfile = UserProfile( + id: 'user1', + name: 'John Doe', + email: 'john@example.com', + age: 30, + ); + + expect(userProfile.id, 'user1'); + expect(userProfile.name, 'John Doe'); + expect(userProfile.email, 'john@example.com'); + expect(userProfile.age, 30); + + // Test JSON serialization + final json = userProfile.toJson(); + expect(json['id'], 'user1'); + expect(json['name'], 'John Doe'); + expect(json['email'], 'john@example.com'); + expect(json['age'], 30); + + // Test JSON deserialization + final fromJson = UserProfile.fromJson(json); + expect(fromJson.id, userProfile.id); + expect(fromJson.name, userProfile.name); + expect(fromJson.email, userProfile.email); + expect(fromJson.age, userProfile.age); + }); + + test('AppSettings model can be created and serialized', () { + const settings = AppSettings(theme: 'dark', notifications: false); + + expect(settings.theme, 'dark'); + expect(settings.notifications, false); + + // Test JSON serialization + final json = settings.toJson(); + expect(json['theme'], 'dark'); + expect(json['notifications'], false); + + // Test JSON deserialization + final fromJson = AppSettings.fromJson(json); + expect(fromJson.theme, settings.theme); + expect(fromJson.notifications, settings.notifications); + }); + + test('AppSettings copyWith works correctly', () { + const originalSettings = AppSettings(theme: 'light', notifications: true); + + final updatedTheme = originalSettings.copyWith(theme: 'dark'); + expect(updatedTheme.theme, 'dark'); + expect(updatedTheme.notifications, true); + + final updatedNotifications = originalSettings.copyWith(notifications: false); + expect(updatedNotifications.theme, 'light'); + expect(updatedNotifications.notifications, false); + + final updatedBoth = originalSettings.copyWith(theme: 'dark', notifications: false); + expect(updatedBoth.theme, 'dark'); + expect(updatedBoth.notifications, false); + }); + + test('Post model can be created and serialized', () { + final now = DateTime.now(); + final post = Post( + id: 'post1', + title: 'Test Post', + content: 'This is a test post content', + authorId: 'user1', + createdAt: now, + ); + + expect(post.id, 'post1'); + expect(post.title, 'Test Post'); + expect(post.content, 'This is a test post content'); + expect(post.authorId, 'user1'); + expect(post.createdAt, now); + + // Test JSON serialization + final json = post.toJson(); + expect(json['id'], 'post1'); + expect(json['title'], 'Test Post'); + expect(json['content'], 'This is a test post content'); + expect(json['authorId'], 'user1'); + expect(json['createdAt'], Timestamp.fromDate(now)); + + // Test JSON deserialization + final fromJson = Post.fromJson(json); + expect(fromJson.id, post.id); + expect(fromJson.title, post.title); + expect(fromJson.content, post.content); + expect(fromJson.authorId, post.authorId); + expect(fromJson.createdAt, post.createdAt); + }); + + test('Firestore collection references are accessible', () { + // Test that both Firestore ODM collection references are accessible + expect(userProfileRef, isNotNull); + expect(userProfileRef.path, 'user-profiles'); + + expect(userProfileRef.doc('1').posts, isNotNull); + expect(userProfileRef.doc('1').posts.path, 'user-profiles/1/posts'); + }); + + test('Riverpod providers are properly generated', () { + // Test that Riverpod providers are accessible + // Note: We can't test the actual provider behavior without a ProviderContainer, + // but we can verify the providers are generated correctly by checking they exist + expect(userProfilesCollectionProvider, isNotNull); + expect(userProfileProvider, isNotNull); + expect(allUserProfilesProvider, isNotNull); + expect(appSettingsProvider, isNotNull); + expect(postsByAuthorProvider, isNotNull); + expect(recentPostsProvider, isNotNull); + }); + }); + + group('Build Runner Integration', () { + test('verifies that both cloud_firestore_odm and riverpod code generation coexist', () { + // This test ensures that the build runner can handle both generators + // without conflicts. The fact that we can import and use both generated + // classes and providers in the same file proves this works. + + // Test Firestore ODM generated code + expect(userProfileRef.doc('test'), isNotNull); + expect(userProfileRef.doc('test').posts.doc('test'), isNotNull); + + // Test that we can create instances of both types + const userProfile = UserProfile(id: '1', name: 'Test', email: 'test@test.com'); + final post = Post( + id: '1', + title: 'Test', + content: 'Content', + authorId: '1', + createdAt: DateTime.now(), + ); + + expect(userProfile, isA()); + expect(post, isA()); + }); + }); +} diff --git a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart index b406e47..f0ffbd4 100644 --- a/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart +++ b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart @@ -2,13 +2,55 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart'; import 'package:flutter_test/flutter_test.dart'; -Future setupCloudFirestoreMocks() async { +void setupFirestoreMocks() { TestWidgetsFlutterBinding.ensureInitialized(); - setupFirebaseCoreMocks(); - await Firebase.initializeApp(); + // Mock Platform Interface + final platform = FirebasePlatform.instance; + if (platform is! MockFirebasePlatform) { + // Register Mock if not already registered + FirebasePlatform.instance = MockFirebasePlatform(); + } +} + +class MockFirebasePlatform extends FirebasePlatform { + @override + Future initializeApp({ + String? name, + FirebaseOptions? options, + }) async { + return MockFirebaseAppPlatform(); + } + + @override + FirebaseAppPlatform app([String name = defaultFirebaseAppName]) { + return MockFirebaseAppPlatform(); + } +} + +class MockFirebaseAppPlatform extends FirebaseAppPlatform { + MockFirebaseAppPlatform() + : super( + defaultFirebaseAppName, + const FirebaseOptions( + apiKey: 'mock-api-key', + appId: 'mock-app-id', + messagingSenderId: 'mock-sender-id', + projectId: 'mock-project-id', + ), + ); + + @override + String get name => defaultFirebaseAppName; + + @override + FirebaseOptions get options => const FirebaseOptions( + apiKey: 'mock-api-key', + appId: 'mock-app-id', + messagingSenderId: 'mock-sender-id', + projectId: 'mock-project-id', + ); } diff --git a/packages/cloud_firestore_odm_generator/lib/cloud_firestore_odm_generator.dart b/packages/cloud_firestore_odm_generator/lib/cloud_firestore_odm_generator.dart index b9908f5..ccd6c7b 100644 --- a/packages/cloud_firestore_odm_generator/lib/cloud_firestore_odm_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/cloud_firestore_odm_generator.dart @@ -10,11 +10,6 @@ import 'src/validator_generator.dart'; /// Builds generators for `build_runner` to run Builder firebase(BuilderOptions options) { - return SharedPartBuilder( - [ - CollectionGenerator(), - ValidatorGenerator(), - ], - 'firebase', - ); + // return SharedPartBuilder([CollectionGenerator(), ValidatorGenerator()], 'firebase'); + return PartBuilder([CollectionGenerator(), ValidatorGenerator()], '.firebase.dart'); } diff --git a/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart index 83ad3ec..55b7616 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart @@ -15,9 +15,9 @@ import 'package:source_helper/source_helper.dart'; import 'collection_generator.dart'; import 'names.dart'; -const collectionChecker = TypeChecker.fromRuntime(Collection); -const jsonSerializableChecker = TypeChecker.fromRuntime(JsonSerializable); -const freezedChecker = TypeChecker.fromRuntime(Freezed); +const collectionChecker = TypeChecker.typeNamed(Collection); +const jsonSerializableChecker = TypeChecker.typeNamed(JsonSerializable); +const freezedChecker = TypeChecker.typeNamed(Freezed); class CollectionGraph { CollectionGraph._(this.roots, this.subCollections); @@ -88,8 +88,7 @@ class CollectionData with Names { required this.perFieldToJson, required this.idKey, required this.libraryElement, - }) : collectionName = - collectionName ?? ReCase(path.split('/').last).camelCase; + }) : collectionName = collectionName ?? ReCase(path.split('/').last).camelCase; factory CollectionData.fromAnnotation({ required LibraryElement libraryElement, @@ -127,18 +126,14 @@ class CollectionData with Names { } final hasFreezed = freezedChecker.hasAnnotationOf(collectionTargetElement); - final redirectedFreezedConstructors = - collectionTargetElement.constructors.where( - (element) { - return element.isFactory && - // It should be safe to read "redirectedConstructor" as the build.yaml - // asks to run the ODM after Freezed - element.redirectedConstructor != null; - }, - ).toList(); + final redirectedFreezedConstructors = collectionTargetElement.constructors2.where((element) { + return element.isFactory && + // It should be safe to read "redirectedConstructor" as the build.yaml + // asks to run the ODM after Freezed + element.redirectedConstructor2 != null; + }).toList(); - final hasJsonSerializable = - jsonSerializableChecker.hasAnnotationOf(collectionTargetElement); + final hasJsonSerializable = jsonSerializableChecker.hasAnnotationOf(collectionTargetElement); // Freezed classes are also JsonSerializable if (!hasJsonSerializable && !hasFreezed) { throw InvalidGenerationSourceError( @@ -147,24 +142,21 @@ class CollectionData with Names { ); } - final annotatedElementSource = annotatedElement.librarySource; + final annotatedElementSource = annotatedElement.library; // TODO(rrousselGit) handle parts // Whether the model class and the reference variable are defined in the same file // This is important because json_serializable generates private code for // decoding a Model class. final modelAndReferenceInTheSameLibrary = - collectionTargetElement.librarySource == annotatedElementSource; + collectionTargetElement.library == annotatedElementSource; if (!modelAndReferenceInTheSameLibrary) { - throw InvalidGenerationSourceError( - ''' + throw InvalidGenerationSourceError(''' When using json_serializable, the `@Collection` annotation and the class that represents the content of the collection must be in the same file. - @Collection is from $annotatedElementSource -- `$collectionTargetElement` is from ${collectionTargetElement.librarySource} -''', - element: annotatedElement, - ); +- `$collectionTargetElement` is from ${collectionTargetElement.library} +''', element: annotatedElement); } // TODO test error handling @@ -175,14 +167,14 @@ represents the content of the collection must be in the same file. ); } - final collectionTargetElementPublicType = - collectionTargetElement.name.public; - final fromJson = collectionTargetElement.constructors - .firstWhereOrNull((ctor) => ctor.name == 'fromJson'); + final collectionTargetElementPublicType = collectionTargetElement.name?.public ?? ''; + final fromJson = collectionTargetElement.constructors2.firstWhereOrNull( + (ctor) => ctor.name == 'fromJson', + ); if (fromJson != null) { - if (fromJson.parameters.length != 1 || - !fromJson.parameters.first.isRequiredPositional || - !fromJson.parameters.first.type.isDartCoreMap) { + if (fromJson.formalParameters.length != 1 || + !fromJson.formalParameters.first.isRequiredPositional || + !fromJson.formalParameters.last.type.isDartCoreMap) { // TODO support deserializing generic objects throw InvalidGenerationSourceError( '@Collection was used with the class ${collectionTargetElement.name} but ' @@ -195,15 +187,15 @@ represents the content of the collection must be in the same file. // Looking into fromJson from superTypes too .allMethods .firstWhereOrNull((method) => method.name == 'toJson'); - final redirectedFreezedClass = redirectedFreezedConstructors - .singleOrNull?.redirectedConstructor!.enclosingElement.name; + final redirectedFreezedClass = + redirectedFreezedConstructors.singleOrNull?.redirectedConstructor2!.enclosingElement.name; final generatedJsonTypePrefix = _generatedJsonTypePrefix( hasFreezed: hasFreezed, redirectedFreezedClass: redirectedFreezedClass, collectionTargetElementPublicType: collectionTargetElementPublicType, ); if (toJson != null) { - if (toJson.parameters.isNotEmpty || !toJson.returnType.isDartCoreMap) { + if (toJson.formalParameters.isNotEmpty || !toJson.returnType.isDartCoreMap) { // TODO support serializing generic objects throw InvalidGenerationSourceError( '@Collection was used with the class ${collectionTargetElement.name} but ' @@ -226,13 +218,9 @@ represents the content of the collection must be in the same file. if (toJson != null) return '$value.toJson()'; return '${generatedJsonTypePrefix}ToJson($value)'; }, - perFieldToJson: (field) => - '${generatedJsonTypePrefix}PerFieldToJson.$field', + perFieldToJson: (field) => '${generatedJsonTypePrefix}PerFieldToJson.$field', idKey: collectionTargetElement - .allFields( - hasFreezed: hasFreezed, - freezedConstructors: redirectedFreezedConstructors, - ) + .allFields(hasFreezed: hasFreezed, freezedConstructors: redirectedFreezedConstructors) .firstWhereOrNull((f) => f.hasId()) ?.name, queryableFields: [ @@ -290,16 +278,13 @@ represents the content of the collection must be in the same file. updatable: false, ), ...collectionTargetElement - .allFields( - hasFreezed: hasFreezed, - freezedConstructors: redirectedFreezedConstructors, - ) + .allFields(hasFreezed: hasFreezed, freezedConstructors: redirectedFreezedConstructors) .where((f) => f.isPublic) .where((f) => !f.hasId()) .where((f) => !f.isJsonIgnored()) .map( (f) => QueryingField( - f.name, + f.name!, f.type, whereDoc: '', orderByDoc: '', @@ -313,8 +298,7 @@ represents the content of the collection must be in the same file. final classPrefix = data.classPrefix; - if (globalData.classPrefixesForLibrary[annotatedElementSource] - ?.contains(classPrefix) ?? + if (globalData.classPrefixesForLibrary[annotatedElementSource]?.contains(classPrefix) ?? false) { throw InvalidGenerationSourceError( 'Defined a collection with duplicate class prefix $classPrefix. ' @@ -323,8 +307,7 @@ represents the content of the collection must be in the same file. } globalData.classPrefixesForLibrary[annotatedElementSource] ??= []; - globalData.classPrefixesForLibrary[annotatedElementSource]! - .add(classPrefix); + globalData.classPrefixesForLibrary[annotatedElementSource]!.add(classPrefix); return data; } @@ -377,7 +360,9 @@ represents the content of the collection must be in the same file. required String collectionTargetElementPublicType, }) { if (hasFreezed) { - return '_\$\$${redirectedFreezedClass?.public}Impl'; + final className = redirectedFreezedClass?.public ?? collectionTargetElementPublicType; + // Only support freezed 3.x or higher + return '_\$$className'; } else { return '_\$$collectionTargetElementPublicType'; } @@ -394,8 +379,7 @@ represents the content of the collection must be in the same file. final List queryableFields; final LibraryElement libraryElement; - late final updatableFields = - queryableFields.where((element) => element.updatable).toList(); + late final updatableFields = queryableFields.where((element) => element.updatable).toList(); CollectionData? _parent; CollectionData? get parent => _parent; @@ -415,10 +399,10 @@ represents the content of the collection must be in the same file. extension on ClassElement { Iterable get allMethods sync* { - yield* methods; + yield* methods2; for (final supertype in allSupertypes) { if (supertype.isDartCoreObject) continue; - yield* supertype.methods; + yield* supertype.methods2; } } @@ -427,20 +411,31 @@ extension on ClassElement { required List freezedConstructors, }) { if (hasFreezed) { - return freezedConstructors.single.parameters; + /// For Freezed 3.x, support mixed mode classes. There can be the classic freezed way with a factory, + /// or there can be simple regular classes with a normal constructor. + /// + /// We need to find the factory constructor, or the normal constructor if there is no factory. + final factoryConstructor = freezedConstructors.firstWhereOrNull( + (ctor) => ctor.isFactory && !ctor.name!.startsWith('_') && ctor.name != 'fromJson', + ); + if (factoryConstructor == null) { + // No factory constructor, use the normal constructor + return fields2; + } + return factoryConstructor.formalParameters; } else { final uniqueFields = {}; - final allFields = const [].followedBy(fields).followedBy( - allSupertypes - .where((e) => !e.isDartCoreObject) - .expand((e) => e.element.fields), + final allFields = const [] + .followedBy(fields2) + .followedBy( + allSupertypes.where((e) => !e.isDartCoreObject).expand((e) => e.element.fields2), ); for (final field in allFields) { - if (field.getter != null && !field.getter!.isSynthetic) continue; + if (field.getter2 != null && !field.getter2!.isSynthetic) continue; if (field.isStatic) continue; - uniqueFields[field.name] ??= field; + uniqueFields[field.name!] ??= field; } return uniqueFields.values; } @@ -458,9 +453,8 @@ const _coreSetChecker = TypeChecker.fromUrl('dart:core#Set'); extension DartTypeExtension on DartType { bool get isJsonDocumentReference { - return element?.librarySource?.uri.scheme == 'package' && - const {'cloud_firestore'} - .contains(element?.librarySource?.uri.pathSegments.first) && + return element?.library?.uri.scheme == 'package' && + const {'cloud_firestore'}.contains(element?.library?.uri.pathSegments.first) && element?.name == 'DocumentReference' && (this as InterfaceType).typeArguments.single.isDartCoreMap; } @@ -485,7 +479,7 @@ extension DartTypeExtension on DartType { extension on Element { bool isJsonIgnored() { - const checker = TypeChecker.fromRuntime(JsonKey); + const checker = TypeChecker.typeNamed(JsonKey); final jsonKeys = checker.annotationsOf(this); for (final jsonKey in jsonKeys) { @@ -494,7 +488,7 @@ extension on Element { // ignore is deprecated in favor of includeFromJson and includeToJson final jsonIncluded = (jsonKey.getField('includeFromJson')?.toBoolValue() ?? true) && - (jsonKey.getField('includeToJson')?.toBoolValue() ?? true); + (jsonKey.getField('includeToJson')?.toBoolValue() ?? true); if (ignore || !jsonIncluded) { return true; } @@ -504,7 +498,7 @@ extension on Element { } bool hasId() { - const checker = TypeChecker.fromRuntime(Id); + const checker = TypeChecker.typeNamed(Id); return checker.hasAnnotationOf(this); } } diff --git a/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart b/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart index b88cde5..4eb8ea7 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart @@ -20,7 +20,7 @@ import 'templates/query_document_snapshot.dart'; import 'templates/query_reference.dart'; import 'templates/query_snapshot.dart'; -const namedQueryChecker = TypeChecker.fromRuntime(NamedQuery); +const namedQueryChecker = TypeChecker.typeNamed(NamedQuery); class QueryingField { QueryingField( @@ -63,24 +63,21 @@ class GlobalData { } @immutable -class CollectionGenerator - extends ParserGenerator> { +class CollectionGenerator extends ParserGenerator> { @override - GlobalData parseGlobalData(LibraryElement library) { + GlobalData parseGlobalData(LibraryElement element) { final globalData = GlobalData(); - for (final element in library.topLevelElements) { + for (final element in element.topLevelVariables) { for (final queryAnnotation in namedQueryChecker.annotationsOf(element)) { final queryData = NamedQueryData.fromAnnotation(queryAnnotation); - final hasCollectionWithMatchingModelType = - collectionChecker.annotationsOf(element).any( - (annotation) { - final collectionType = - CollectionData.modelTypeOfAnnotation(annotation); - return collectionType == queryData.type; - }, - ); + final hasCollectionWithMatchingModelType = collectionChecker.annotationsOf(element).any(( + annotation, + ) { + final collectionType = CollectionData.modelTypeOfAnnotation(annotation); + return collectionType == queryData.type; + }); if (!hasCollectionWithMatchingModelType) { throw InvalidGenerationSourceError( @@ -103,17 +100,15 @@ class CollectionGenerator GlobalData globalData, Element element, ) async { - final library = await buildStep.inputLibrary; - final collectionAnnotations = collectionChecker.annotationsOf(element).map( - (annotation) { - return CollectionData.fromAnnotation( - annotatedElement: element, - globalData: globalData, - libraryElement: library, - annotation: annotation, - ); - }, - ).toList(); + final libraryElement = await buildStep.inputLibrary; + final collectionAnnotations = collectionChecker.annotationsOf(element).map((annotation) { + return CollectionData.fromAnnotation( + annotatedElement: element, + globalData: globalData, + libraryElement: libraryElement, + annotation: annotation, + ); + }).toList(); return CollectionGraph.parse(collectionAnnotations); } @@ -141,10 +136,7 @@ const _sentinel = _Sentinel(); } @override - Iterable generateForData( - GlobalData globalData, - CollectionGraph data, - ) sync* { + Iterable generateForData(GlobalData globalData, CollectionGraph data) sync* { for (final collection in data.allCollections) { yield CollectionReferenceTemplate(collection); yield DocumentReferenceTemplate(collection); diff --git a/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart b/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart index 9d04385..2d4f944 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart @@ -8,67 +8,37 @@ import 'package:analyzer/dart/element/element.dart'; import 'package:build/build.dart'; import 'package:source_gen/source_gen.dart'; -abstract class ParserGenerator - extends GeneratorForAnnotation { - @override - FutureOr generate( - // ignore: avoid_renaming_method_parameters - LibraryReader oldLibrary, - BuildStep buildStep, - ) async { - final library = await buildStep.resolver.libraryFor( - await buildStep.resolver.assetIdForElement(oldLibrary.element), - ); +import 'collection_data.dart'; +import 'collection_generator.dart'; +abstract class ParserGenerator extends GeneratorForAnnotation { + @override + FutureOr generate(LibraryReader library, BuildStep buildStep) async { + final element = library.element; final generationBuffer = StringBuffer(); // A set used to remove duplicate generations. This is for scenarios where // two annotations within the library want to generate the same code final generatedCache = {}; - final globalData = parseGlobalData(library); - - var hasGeneratedGlobalCode = false; - - for (final element - in library.topLevelElements.where(typeChecker.hasAnnotationOf)) { - if (!hasGeneratedGlobalCode) { - hasGeneratedGlobalCode = true; - for (final generated - in generateForAll(globalData).map((e) => e.toString())) { - assert(generated.length == generated.trim().length); - if (generatedCache.add(generated)) { - generationBuffer.writeln(generated); - } - } - } - - final data = await parseElement(buildStep, globalData, element); - if (data == null) continue; - - for (final generated - in generateForData(globalData, data).map((e) => e.toString())) { - assert(generated.length == generated.trim().length); - - if (generatedCache.add(generated)) { - generationBuffer.writeln(generated); - } + final globalData = parseGlobalData(element); + for (final generated in generateForAll(globalData).map((e) => e.toString())) { + assert(generated.length == generated.trim().length); + if (generatedCache.add(generated)) { + generationBuffer.writeln(generated); } } - return generationBuffer.toString(); + final superGenerated = await super.generate(library, buildStep); + return '$generationBuffer\n\n$superGenerated'; } Iterable generateForAll(GlobalData globalData) sync* {} GlobalData parseGlobalData(LibraryElement library); - FutureOr parseElement( - BuildStep buildStep, - GlobalData globalData, - Element element, - ); + Future parseElement(BuildStep buildStep, GlobalData globalData, Element element); - Iterable generateForData(GlobalData globalData, Data data); + Iterable generateForData(GlobalData globalData, CollectionGraph data); @override Stream generateForAnnotatedElement( @@ -78,11 +48,9 @@ abstract class ParserGenerator ) async* { // implemented for source_gen_test – otherwise unused final globalData = parseGlobalData(element.library!); - final data = parseElement(buildStep, globalData, element); - - if (data == null) return; + final data = await parseElement(buildStep, globalData, element); - for (final value in generateForData(globalData, await data)) { + for (final value in generateForData(globalData, data)) { yield value.toString(); } } 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 7f7104a..2975b4b 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 @@ -193,12 +193,28 @@ void batchSet( fieldValuesNullable: true, ); final fieldValuesJson = _json(data, includeFields: false); + final json = ''' { ...${data.toJson('model')}, $fieldValuesJson }'''; + final idKey = data.idKey; + + String toFirestoreBody; + if (idKey != null) { + toFirestoreBody = "value..remove('$idKey')"; + } else { + toFirestoreBody = 'value'; + } + + final castedReferenceStr = ''' +reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => $toFirestoreBody, +)'''; + return ''' Future set( $type model, { @@ -207,10 +223,7 @@ Future set( }) async { final json = $json; - final castedReference = reference.withConverter>( - fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, - ); + final castedReference = $castedReferenceStr; return castedReference.set(json, options); } @@ -222,7 +235,8 @@ void transactionSet( }) { final json = $json; - transaction.set(reference, json, options); + final castedReference = $castedReferenceStr; + transaction.set(castedReference, json, options); } void batchSet( @@ -233,7 +247,8 @@ void batchSet( }) { final json = $json; - batch.set(reference, json, options); + final castedReference = $castedReferenceStr; + batch.set(castedReference, json, options); } '''; } diff --git a/packages/cloud_firestore_odm_generator/lib/src/templates/query_reference.dart b/packages/cloud_firestore_odm_generator/lib/src/templates/query_reference.dart index 72d9517..d6bcffa 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/templates/query_reference.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/templates/query_reference.dart @@ -149,6 +149,12 @@ class ${data.queryReferenceImplName} if (field.name == 'fieldPath') '${field.type} fieldPath,', ].join(); + String withToJson(String arg) { + return field.name == 'documentId' || field.name == 'fieldPath' + ? arg + : '${data.perFieldToJson(field.name)}($arg as ${field.type})'; + } + buffer.writeln( ''' @override @@ -193,25 +199,25 @@ class ${data.queryReferenceImplName} if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [...queryCursor.startAt, ${withToJson('startAt')}], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [...queryCursor.startAfter, ${withToJson('startAfter')}], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [...queryCursor.endAt, ${withToJson('endAt')}], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [...queryCursor.endBefore, ${withToJson('endBefore')}], endBeforeDocumentSnapshot: null, ); } @@ -238,14 +244,12 @@ class ${data.queryReferenceImplName} (match) => match.group(0)!.toUpperCase(), ); - final nullableType = - field.type.nullabilitySuffix == NullabilitySuffix.question - ? '${field.type}' - : '${field.type}?'; + final nullableType = field.type.nullabilitySuffix == NullabilitySuffix.question + ? '${field.type}' + : '${field.type}?'; final nullableWhereType = _WherePrototype.plain(nullableType); - final sentinelObjectWhereType = - _WherePrototype.plain('Object?', '_sentinel'); + final sentinelObjectWhereType = _WherePrototype.plain('Object?', '_sentinel'); final objectWhereType = _WherePrototype.plain('Object?'); final perFieldToJson = data.perFieldToJson(field.name); @@ -322,10 +326,7 @@ class ${data.queryReferenceImplName} map: (name) { final itemType = field.name == 'fieldPath' ? field.type.toString() - : (field.type as InterfaceType) - .typeArguments - .first - .toString(); + : (field.type as InterfaceType).typeArguments.first.toString(); final cast = itemType != 'Object?' ? ' as $itemType' : ''; var transform = '$name != null ? ($perFieldToJson('; @@ -339,8 +340,7 @@ class ${data.queryReferenceImplName} ), 'arrayContainsAny': _WhereMapper( prototype: nullableWhereType, - map: (name) => - '$name != null ? $perFieldToJson($name) as Iterable? : null', + map: (name) => '$name != null ? $perFieldToJson($name) as Iterable? : null', ), } else if (!field.type.isSupportedIterable) ...{ 'whereIn': inMapper, @@ -354,8 +354,7 @@ class ${data.queryReferenceImplName} ), }; - final prototype = - operators.entries.map((e) => e.value.prototype.call(e.key)).join(); + final prototype = operators.entries.map((e) => e.value.prototype.call(e.key)).join(); final parameters = operators.entries.map((entry) { final key = entry.key; diff --git a/packages/cloud_firestore_odm_generator/lib/src/utils/errors.dart b/packages/cloud_firestore_odm_generator/lib/src/utils/errors.dart new file mode 100644 index 0000000..a53b473 --- /dev/null +++ b/packages/cloud_firestore_odm_generator/lib/src/utils/errors.dart @@ -0,0 +1,25 @@ +import 'package:analyzer/dart/ast/ast.dart'; + +typedef CollectionErrorReporter = void Function(CollectionAnalysisError); + +CollectionErrorReporter errorReporter = (error) { + throw UnsupportedError('CollectionAnalysisError found but no errorReporter specified: $error'); +}; + +enum CollectionAnalysisErrorCode { missing } + +class CollectionAnalysisError { + CollectionAnalysisError.ast(this.message, {required this.targetNode, required this.code}); + + final String message; + final AstNode targetNode; + final CollectionAnalysisErrorCode? code; + + @override + String toString() { + var trailing = ''; + trailing += ' ; node: $targetNode (${targetNode.runtimeType})'; + + return 'CollectionAnalysisError: $message$trailing'; + } +} diff --git a/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart b/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart index 44e7a89..c3f83d0 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart @@ -15,7 +15,7 @@ class ValidatorGenerator extends Generator { for (final classElement in library.classes) { final validations = classElement.fields.expand((field) sync* { - final validators = field.metadata.where(isValidatorAnnotation); + final validators = field.metadata.annotations.where(isValidatorAnnotation); for (final validator in validators) { yield "${validator.toSource().replaceFirst('@', 'const ')}.validate(instance.${field.name}, '${field.name}');"; @@ -24,9 +24,7 @@ class ValidatorGenerator extends Generator { if (validations.isNotEmpty) { buffer - ..write( - 'void _\$assert${classElement.name}(${classElement.name} instance) {', - ) + ..write('void _\$assert${classElement.name}(${classElement.name} instance) {') ..writeAll(validations) ..write('}'); } @@ -42,7 +40,7 @@ bool isValidatorAnnotation(ElementAnnotation annotation) { return element.enclosingElement.allSupertypes.any((superType) { return superType.element.name == 'Validator' && - superType.element.librarySource.uri.toString() == + superType.element.library.uri.toString() == 'package:cloud_firestore_odm/src/validator.dart'; }); } diff --git a/packages/cloud_firestore_odm_generator/pubspec.yaml b/packages/cloud_firestore_odm_generator/pubspec.yaml index fdab7d5..440cf1c 100644 --- a/packages/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/pubspec.yaml @@ -2,29 +2,32 @@ 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.90 +version: 2.0.0 environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ">=3.9.2 <4.0.0" dependencies: - analyzer: ">=5.12.0 <7.0.0" - build: ^2.0.1 - build_config: ^1.0.0 - cloud_firestore_odm: ^1.0.0-dev.87 - collection: ^1.15.0 - freezed_annotation: ">=1.0.0 <3.0.0" - # Can be removed once this is fixed https://github.com/dart-lang/graphs/issues/86 - graphs: ^2.0.0 - json_annotation: ^4.8.1 - meta: ^1.8.0 - recase: ^4.0.0 - source_gen: ^1.3.2 - source_helper: ^1.3.4 + analyzer: ^8.0.0 + build: ^4.0.0 + cloud_firestore_odm: ^2.0.0 + # For testing locally + # cloud_firestore_odm: + # path: ../cloud_firestore_odm + collection: ^1.18.0 + freezed_annotation: ^3.0.0 + json_annotation: ^4.9.0 + meta: ^1.12.0 + recase: ^4.1.0 + source_gen: ^4.0.1 + source_helper: ^1.3.7 dev_dependencies: - build_runner: ^2.4.2 - expect_error: ^1.0.5 - json_serializable: ">=6.3.0 <7.0.0" - matcher: ^0.12.10 - test: ^1.16.8 + build_runner: ^2.8.0 + expect_error: ^1.0.10 + json_serializable: ^6.11.0 + matcher: ^0.12.17 + test: ^1.26.3 + +dependency_overrides: + test_api: ^0.7.7 diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh new file mode 100755 index 0000000..49d5368 --- /dev/null +++ b/scripts/run-tests.sh @@ -0,0 +1,22 @@ +cd packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test +dart run build_runner build -d +flutter test +cd .. +dart test +cd ../cloud_firestore_odm +flutter test +cd example +dart run build_runner build -d +firebase emulators:start --only firestore & +FIREBASE_EMULATOR_PID=$! + +chromedriver --port=4444 & +CHROMEDRIVER_PID=$! + +flutter drive --driver=test_driver/integration_test.dart --target=integration_test/cloud_firestore_odm_e2e_test.dart -d chrome +kill $CHROMEDRIVER_PID +kill $FIREBASE_EMULATOR_PID + + + +