From e73305482367ea51b6463fbe8a7be27d1b57ade3 Mon Sep 17 00:00:00 2001 From: dorklein Date: Wed, 5 Mar 2025 14:43:59 +0200 Subject: [PATCH 1/8] Update cloud_firestore_odm to support Freezed 3.0.0 and latest dependencies - Resolve compatibility issues with Freezed 3.0.0 and above - Update Dart SDK to >=3.0.0 - Upgrade dependencies to latest versions - Add support for Freezed mixed mode classes - Update generator to handle new Freezed class structures - Improve compatibility with newer analyzer and source_gen versions --- README.md | 8 +- packages/cloud_firestore_odm/CHANGELOG.md | 6 + packages/cloud_firestore_odm/README.md | 6 + .../example/lib/integration.g.dart | 2 +- .../example/lib/integration/freezed.dart | 4 +- .../lib/integration/freezed.freezed.dart | 358 +++--- .../example/lib/integration/freezed.g.dart | 170 ++- .../cloud_firestore_odm/example/pubspec.yaml | 14 +- packages/cloud_firestore_odm/pubspec.yaml | 9 +- .../CHANGELOG.md | 6 + .../lib/freezed.dart | 19 +- .../lib/freezed.freezed.dart | 403 +++--- .../lib/freezed.g.dart | 1137 +++++++++++++++-- .../pubspec.yaml | 18 +- .../test/collection_test.dart | 23 +- .../test/setup_firestore_mock.dart | 52 +- .../lib/src/collection_data.dart | 23 +- .../lib/src/validator_generator.dart | 2 +- .../pubspec.yaml | 36 +- 19 files changed, 1684 insertions(+), 612 deletions(-) diff --git a/README.md b/README.md index 5633a8b..f7a4df6 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.0.0 <4.0.0" ``` ### 2. FlutterFire Initialization diff --git a/packages/cloud_firestore_odm/CHANGELOG.md b/packages/cloud_firestore_odm/CHANGELOG.md index aec44da..1ccb554 100644 --- a/packages/cloud_firestore_odm/CHANGELOG.md +++ b/packages/cloud_firestore_odm/CHANGELOG.md @@ -1,3 +1,9 @@ +## 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/lib/integration.g.dart b/packages/cloud_firestore_odm/example/lib/integration.g.dart index 0ea7bee..71f4646 100644 --- a/packages/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint, type=warning +// ignore_for_file: type=lint part of 'integration.dart'; diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.dart index 4453f8b..483385a 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.dart @@ -13,7 +13,7 @@ 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,7 +28,7 @@ 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) => 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..aa734d6 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint @@ -9,85 +10,53 @@ 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; + String get firstName; @JsonKey(name: 'LAST_NAME') - String get lastName => throw _privateConstructorUsedError; + String get lastName; @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored => throw _privateConstructorUsedError; - - /// Serializes this Person to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + int? get ignored; /// 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; -} + @pragma('vm:prefer-inline') + $PersonCopyWith get copyWith => + _$PersonCopyWithImpl(this as Person, _$identity); -/// @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}); -} + /// Serializes this Person to a JSON map. + Map toJson(); -/// @nodoc -class _$PersonCopyWithImpl<$Res, $Val extends Person> - implements $PersonCopyWith<$Res> { - _$PersonCopyWithImpl(this._value, this._then); + @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)); + } - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + @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. - @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); + String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; } } /// @nodoc -abstract class _$$PersonImplCopyWith<$Res> implements $PersonCopyWith<$Res> { - factory _$$PersonImplCopyWith( - _$PersonImpl value, $Res Function(_$PersonImpl) then) = - __$$PersonImplCopyWithImpl<$Res>; - @override +abstract mixin class $PersonCopyWith<$Res> { + factory $PersonCopyWith(Person value, $Res Function(Person) _then) = + _$PersonCopyWithImpl; @useResult $Res call( {String firstName, @@ -96,12 +65,11 @@ abstract class _$$PersonImplCopyWith<$Res> implements $PersonCopyWith<$Res> { } /// @nodoc -class __$$PersonImplCopyWithImpl<$Res> - extends _$PersonCopyWithImpl<$Res, _$PersonImpl> - implements _$$PersonImplCopyWith<$Res> { - __$$PersonImplCopyWithImpl( - _$PersonImpl _value, $Res Function(_$PersonImpl) _then) - : super(_value, _then); +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. @@ -112,17 +80,17 @@ class __$$PersonImplCopyWithImpl<$Res> Object? lastName = null, Object? ignored = freezed, }) { - return _then(_$PersonImpl( + return _then(_self.copyWith( firstName: null == firstName - ? _value.firstName + ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable as String, lastName: null == lastName - ? _value.lastName + ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable as String, ignored: freezed == ignored - ? _value.ignored + ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable as int?, )); @@ -132,14 +100,12 @@ class __$$PersonImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable(fieldRename: FieldRename.snake) -class _$PersonImpl implements _Person { - _$PersonImpl( +class _Person implements Person { + _Person( {required this.firstName, @JsonKey(name: 'LAST_NAME') required this.lastName, @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); - - factory _$PersonImpl.fromJson(Map json) => - _$$PersonImplFromJson(json); + factory _Person.fromJson(Map json) => _$PersonFromJson(json); @override final String firstName; @@ -150,16 +116,26 @@ class _$PersonImpl implements _Person { @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 - String toString() { - return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; + @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 _$PersonImpl && + other is _Person && (identical(other.firstName, firstName) || other.firstName == firstName) && (identical(other.lastName, lastName) || @@ -171,46 +147,55 @@ class _$PersonImpl implements _Person { @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, - ); + 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; +/// @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; +/// @nodoc +class __$PersonCopyWithImpl<$Res> implements _$PersonCopyWith<$Res> { + __$PersonCopyWithImpl(this._self, this._then); - @override - String get firstName; - @override - @JsonKey(name: 'LAST_NAME') - String get lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored; + 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 - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - throw _privateConstructorUsedError; + @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) { @@ -219,71 +204,53 @@ PublicRedirected _$PublicRedirectedFromJson(Map json) { /// @nodoc mixin _$PublicRedirected { - String get value => throw _privateConstructorUsedError; - - /// Serializes this PublicRedirected to a JSON map. - Map toJson() => 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 => - throw _privateConstructorUsedError; -} + _$PublicRedirectedCopyWithImpl( + this as PublicRedirected, _$identity); -/// @nodoc -abstract class $PublicRedirectedCopyWith<$Res> { - factory $PublicRedirectedCopyWith( - PublicRedirected value, $Res Function(PublicRedirected) then) = - _$PublicRedirectedCopyWithImpl<$Res, PublicRedirected>; - @useResult - $Res call({String value}); -} + /// Serializes this PublicRedirected to a JSON map. + Map toJson(); -/// @nodoc -class _$PublicRedirectedCopyWithImpl<$Res, $Val extends PublicRedirected> - implements $PublicRedirectedCopyWith<$Res> { - _$PublicRedirectedCopyWithImpl(this._value, this._then); + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is PublicRedirected && + (identical(other.value, value) || other.value == value)); + } - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + @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. - @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); + String toString() { + return 'PublicRedirected(value: $value)'; } } /// @nodoc -abstract class _$$PublicRedirected2ImplCopyWith<$Res> - implements $PublicRedirectedCopyWith<$Res> { - factory _$$PublicRedirected2ImplCopyWith(_$PublicRedirected2Impl value, - $Res Function(_$PublicRedirected2Impl) then) = - __$$PublicRedirected2ImplCopyWithImpl<$Res>; - @override +abstract mixin class $PublicRedirectedCopyWith<$Res> { + factory $PublicRedirectedCopyWith( + PublicRedirected value, $Res Function(PublicRedirected) _then) = + _$PublicRedirectedCopyWithImpl; @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); +class _$PublicRedirectedCopyWithImpl<$Res> + implements $PublicRedirectedCopyWith<$Res> { + _$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. @@ -292,9 +259,9 @@ class __$$PublicRedirected2ImplCopyWithImpl<$Res> $Res call({ Object? value = null, }) { - return _then(_$PublicRedirected2Impl( + return _then(_self.copyWith( value: null == value - ? _value.value + ? _self.value : value // ignore: cast_nullable_to_non_nullable as String, )); @@ -303,25 +270,34 @@ class __$$PublicRedirected2ImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$PublicRedirected2Impl implements PublicRedirected2 { - _$PublicRedirected2Impl({required this.value}); - - factory _$PublicRedirected2Impl.fromJson(Map json) => - _$$PublicRedirected2ImplFromJson(json); +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 - String toString() { - return 'PublicRedirected(value: $value)'; + @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 _$PublicRedirected2Impl && + other is PublicRedirected2 && (identical(other.value, value) || other.value == value)); } @@ -329,37 +305,45 @@ class _$PublicRedirected2Impl implements PublicRedirected2 { @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, - ); + String toString() { + return 'PublicRedirected(value: $value)'; } } -abstract class PublicRedirected2 implements PublicRedirected { - factory PublicRedirected2({required final String value}) = - _$PublicRedirected2Impl; +/// @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; +/// @nodoc +class _$PublicRedirected2CopyWithImpl<$Res> + implements $PublicRedirected2CopyWith<$Res> { + _$PublicRedirected2CopyWithImpl(this._self, this._then); - @override - String get value; + 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 - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - throw _privateConstructorUsedError; + @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..8cbddce 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart @@ -242,9 +242,9 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; final castedReference = reference.withConverter>( @@ -264,9 +264,9 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; transaction.set(reference, json, options); @@ -282,9 +282,9 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; batch.set(reference, json, options); @@ -306,15 +306,15 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: + _$PersonPerFieldToJson.firstName(firstName as String), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: + _$PersonPerFieldToJson.lastName(lastName as String), if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; return reference.update(json); @@ -337,15 +337,15 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: + _$PersonPerFieldToJson.firstName(firstName as String), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: + _$PersonPerFieldToJson.lastName(lastName as String), if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; transaction.update(reference, json); @@ -368,15 +368,15 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: + _$PersonPerFieldToJson.firstName(firstName as String), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: + _$PersonPerFieldToJson.lastName(lastName as String), if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; batch.update(reference, json); @@ -665,30 +665,27 @@ class _$PersonQuery extends QueryReference return _$PersonQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['firstName']!, + _$PersonFieldMap['firstName']!, isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isNotEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.firstName(isLessThan as String) + ? _$PersonPerFieldToJson.firstName(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isLessThanOrEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.firstName(isGreaterThan as String) + ? _$PersonPerFieldToJson.firstName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), isNull: isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), @@ -712,30 +709,27 @@ class _$PersonQuery extends QueryReference return _$PersonQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['lastName']!, + _$PersonFieldMap['lastName']!, isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isNotEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.lastName(isLessThan as String) + ? _$PersonPerFieldToJson.lastName(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isLessThanOrEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.lastName(isGreaterThan as String) + ? _$PersonPerFieldToJson.lastName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), isNull: isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), @@ -904,7 +898,7 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['firstName']!, descending: descending); + .orderBy(_$PersonFieldMap['firstName']!, descending: descending); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -976,8 +970,8 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['lastName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy(_$PersonFieldMap['lastName']!, + descending: descending); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1350,7 +1344,7 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; final castedReference = reference.withConverter>( @@ -1369,7 +1363,7 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; transaction.set(reference, json, options); @@ -1384,7 +1378,7 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; batch.set(reference, json, options); @@ -1400,10 +1394,10 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: + _$PublicRedirected2PerFieldToJson.value(value as String), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; return reference.update(json); @@ -1420,10 +1414,10 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: + _$PublicRedirected2PerFieldToJson.value(value as String), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; transaction.update(reference, json); @@ -1440,10 +1434,10 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: + _$PublicRedirected2PerFieldToJson.value(value as String), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; batch.update(reference, json); @@ -1713,33 +1707,31 @@ class _$PublicRedirectedQuery return _$PublicRedirectedQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PublicRedirected2ImplFieldMap['value']!, + _$PublicRedirected2FieldMap['value']!, isEqualTo: isEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson.value(isEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isNotEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PublicRedirected2ImplPerFieldToJson.value(isLessThan as String) + ? _$PublicRedirected2PerFieldToJson.value(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson + ? _$PublicRedirected2PerFieldToJson .value(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThan as String) + ? _$PublicRedirected2PerFieldToJson.value(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson + ? _$PublicRedirected2PerFieldToJson .value(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - whereNotIn: whereNotIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), + whereIn: + whereIn?.map((e) => _$PublicRedirected2PerFieldToJson.value(e)), + whereNotIn: + whereNotIn?.map((e) => _$PublicRedirected2PerFieldToJson.value(e)), isNull: isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), @@ -1907,9 +1899,8 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy( - _$$PublicRedirected2ImplFieldMap['value']!, - descending: descending); + final query = $referenceWithoutCursor + .orderBy(_$PublicRedirected2FieldMap['value']!, descending: descending); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2072,48 +2063,45 @@ class PublicRedirectedQueryDocumentSnapshot // JsonSerializableGenerator // ************************************************************************** -_$PersonImpl _$$PersonImplFromJson(Map json) => _$PersonImpl( +_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) => - { +Map _$PersonToJson(_Person instance) => { 'first_name': instance.firstName, 'LAST_NAME': instance.lastName, }; -_$PublicRedirected2Impl _$$PublicRedirected2ImplFromJson( - Map json) => - _$PublicRedirected2Impl( +PublicRedirected2 _$PublicRedirected2FromJson(Map json) => + PublicRedirected2( value: json['value'] as String, ); -const _$$PublicRedirected2ImplFieldMap = { +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) => +Map _$PublicRedirected2ToJson(PublicRedirected2 instance) => { 'value': instance.value, }; diff --git a/packages/cloud_firestore_odm/example/pubspec.yaml b/packages/cloud_firestore_odm/example/pubspec.yaml index f7354cb..a6e669f 100644 --- a/packages/cloud_firestore_odm/example/pubspec.yaml +++ b/packages/cloud_firestore_odm/example/pubspec.yaml @@ -2,16 +2,16 @@ name: cloud_firestore_odm_example publish_to: none environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.0.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 - cloud_firestore_odm: ^1.0.0-dev.85 + cloud_firestore: ^5.6.5 + cloud_firestore_odm: ^1.1.0 firebase_core: ^3.0.0 flutter: sdk: flutter - freezed_annotation: ^2.2.0 - json_annotation: ^4.8.1 + freezed_annotation: ^3.0.0 + json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: @@ -22,11 +22,11 @@ dev_dependencies: path: ../../cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test flutter_test: sdk: flutter - freezed: ^2.3.2 + freezed: ^3.0.0 http: ^1.0.0 integration_test: sdk: flutter - json_serializable: ^6.6.1 + json_serializable: ^6.7.0 mockito: ^5.0.0 dependency_overrides: diff --git a/packages/cloud_firestore_odm/pubspec.yaml b/packages/cloud_firestore_odm/pubspec.yaml index 1873718..84a2941 100644 --- a/packages/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/pubspec.yaml @@ -2,21 +2,22 @@ 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: 1.1.0 false_secrets: - example/** environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.0.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 + cloud_firestore: ^5.0.2 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.25.1 diff --git a/packages/cloud_firestore_odm_generator/CHANGELOG.md b/packages/cloud_firestore_odm_generator/CHANGELOG.md index 28119ba..34cd24c 100644 --- a/packages/cloud_firestore_odm_generator/CHANGELOG.md +++ b/packages/cloud_firestore_odm_generator/CHANGELOG.md @@ -1,3 +1,9 @@ +## 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/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..e8af1d2 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 @@ -13,7 +13,7 @@ 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 +28,24 @@ 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); } + +/// Freezed 3.x mixed mode +/// +/// Simple classes +@Collection('freezed-test') +@freezed +@JsonSerializable() +class SimpleFreezed with _$SimpleFreezed { + SimpleFreezed({required this.a}); + final int a; + + factory SimpleFreezed.fromJson(Map json) => + _$SimpleFreezedFromJson(json); + Map toJson() => _$SimpleFreezedToJson(this); +} 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..661f349 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,3 +1,4 @@ +// dart format width=80 // coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND // ignore_for_file: type=lint @@ -9,85 +10,53 @@ 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; + String get firstName; @JsonKey(name: 'LAST_NAME') - String get lastName => throw _privateConstructorUsedError; + String get lastName; @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored => throw _privateConstructorUsedError; - - /// Serializes this Person to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + int? get ignored; /// 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; -} + @pragma('vm:prefer-inline') + $PersonCopyWith get copyWith => + _$PersonCopyWithImpl(this as Person, _$identity); -/// @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}); -} + /// Serializes this Person to a JSON map. + Map toJson(); -/// @nodoc -class _$PersonCopyWithImpl<$Res, $Val extends Person> - implements $PersonCopyWith<$Res> { - _$PersonCopyWithImpl(this._value, this._then); + @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)); + } - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; + @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. - @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); + String toString() { + return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; } } /// @nodoc -abstract class _$$PersonImplCopyWith<$Res> implements $PersonCopyWith<$Res> { - factory _$$PersonImplCopyWith( - _$PersonImpl value, $Res Function(_$PersonImpl) then) = - __$$PersonImplCopyWithImpl<$Res>; - @override +abstract mixin class $PersonCopyWith<$Res> { + factory $PersonCopyWith(Person value, $Res Function(Person) _then) = + _$PersonCopyWithImpl; @useResult $Res call( {String firstName, @@ -96,12 +65,11 @@ abstract class _$$PersonImplCopyWith<$Res> implements $PersonCopyWith<$Res> { } /// @nodoc -class __$$PersonImplCopyWithImpl<$Res> - extends _$PersonCopyWithImpl<$Res, _$PersonImpl> - implements _$$PersonImplCopyWith<$Res> { - __$$PersonImplCopyWithImpl( - _$PersonImpl _value, $Res Function(_$PersonImpl) _then) - : super(_value, _then); +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. @@ -112,17 +80,17 @@ class __$$PersonImplCopyWithImpl<$Res> Object? lastName = null, Object? ignored = freezed, }) { - return _then(_$PersonImpl( + return _then(_self.copyWith( firstName: null == firstName - ? _value.firstName + ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable as String, lastName: null == lastName - ? _value.lastName + ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable as String, ignored: freezed == ignored - ? _value.ignored + ? _self.ignored : ignored // ignore: cast_nullable_to_non_nullable as int?, )); @@ -132,14 +100,12 @@ class __$$PersonImplCopyWithImpl<$Res> /// @nodoc @JsonSerializable(fieldRename: FieldRename.snake) -class _$PersonImpl implements _Person { - _$PersonImpl( +class _Person implements Person { + _Person( {required this.firstName, @JsonKey(name: 'LAST_NAME') required this.lastName, @JsonKey(includeFromJson: false, includeToJson: false) this.ignored}); - - factory _$PersonImpl.fromJson(Map json) => - _$$PersonImplFromJson(json); + factory _Person.fromJson(Map json) => _$PersonFromJson(json); @override final String firstName; @@ -150,16 +116,26 @@ class _$PersonImpl implements _Person { @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 - String toString() { - return 'Person(firstName: $firstName, lastName: $lastName, ignored: $ignored)'; + @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 _$PersonImpl && + other is _Person && (identical(other.firstName, firstName) || other.firstName == firstName) && (identical(other.lastName, lastName) || @@ -171,46 +147,55 @@ class _$PersonImpl implements _Person { @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, - ); + 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; +/// @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; +/// @nodoc +class __$PersonCopyWithImpl<$Res> implements _$PersonCopyWith<$Res> { + __$PersonCopyWithImpl(this._self, this._then); - @override - String get firstName; - @override - @JsonKey(name: 'LAST_NAME') - String get lastName; - @override - @JsonKey(includeFromJson: false, includeToJson: false) - int? get ignored; + 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 - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PersonImplCopyWith<_$PersonImpl> get copyWith => - throw _privateConstructorUsedError; + @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) { @@ -219,36 +204,53 @@ PublicRedirected _$PublicRedirectedFromJson(Map json) { /// @nodoc mixin _$PublicRedirected { - String get value => throw _privateConstructorUsedError; - - /// Serializes this PublicRedirected to a JSON map. - Map toJson() => 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 => - throw _privateConstructorUsedError; + _$PublicRedirectedCopyWithImpl( + this as PublicRedirected, _$identity); + + /// Serializes this PublicRedirected to a JSON map. + Map toJson(); + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is PublicRedirected && + (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 class $PublicRedirectedCopyWith<$Res> { +abstract mixin class $PublicRedirectedCopyWith<$Res> { factory $PublicRedirectedCopyWith( - PublicRedirected value, $Res Function(PublicRedirected) then) = - _$PublicRedirectedCopyWithImpl<$Res, PublicRedirected>; + 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); + _$PublicRedirectedCopyWithImpl(this._self, this._then); - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _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. @@ -257,44 +259,87 @@ class _$PublicRedirectedCopyWithImpl<$Res, $Val extends PublicRedirected> $Res call({ Object? value = null, }) { - return _then(_value.copyWith( + return _then(_self.copyWith( value: null == value - ? _value.value + ? _self.value : value // ignore: cast_nullable_to_non_nullable as String, - ) as $Val); + )); } } /// @nodoc -abstract class _$$PublicRedirected2ImplCopyWith<$Res> +@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 _$$PublicRedirected2ImplCopyWith(_$PublicRedirected2Impl value, - $Res Function(_$PublicRedirected2Impl) then) = - __$$PublicRedirected2ImplCopyWithImpl<$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); +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. - @pragma('vm:prefer-inline') @override + @pragma('vm:prefer-inline') $Res call({ Object? value = null, }) { - return _then(_$PublicRedirected2Impl( + return _then(PublicRedirected2( value: null == value - ? _value.value + ? _self.value : value // ignore: cast_nullable_to_non_nullable as String, )); @@ -302,64 +347,66 @@ class __$$PublicRedirected2ImplCopyWithImpl<$Res> } /// @nodoc -@JsonSerializable() -class _$PublicRedirected2Impl implements PublicRedirected2 { - _$PublicRedirected2Impl({required this.value}); +mixin _$SimpleFreezed { + int get a; - factory _$PublicRedirected2Impl.fromJson(Map json) => - _$$PublicRedirected2ImplFromJson(json); - - @override - final String value; - - @override - String toString() { - return 'PublicRedirected(value: $value)'; - } + /// 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 _$PublicRedirected2Impl && - (identical(other.value, value) || other.value == value)); + other is SimpleFreezed && + (identical(other.a, a) || other.a == a)); } @JsonKey(includeFromJson: false, includeToJson: false) @override - int get hashCode => Object.hash(runtimeType, value); + int get hashCode => Object.hash(runtimeType, a); - /// 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, - ); + 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}); +} - factory PublicRedirected2.fromJson(Map json) = - _$PublicRedirected2Impl.fromJson; +/// @nodoc +class _$SimpleFreezedCopyWithImpl<$Res> + implements $SimpleFreezedCopyWith<$Res> { + _$SimpleFreezedCopyWithImpl(this._self, this._then); - @override - String get value; + final SimpleFreezed _self; + final $Res Function(SimpleFreezed) _then; - /// Create a copy of PublicRedirected + /// Create a copy of SimpleFreezed /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$PublicRedirected2ImplCopyWith<_$PublicRedirected2Impl> get copyWith => - throw _privateConstructorUsedError; + $Res call({ + Object? a = null, + }) { + return _then(SimpleFreezed( + a: null == a + ? _self.a + : a // 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/freezed.g.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart index 7ca05a2..206181b 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 @@ -240,9 +240,9 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; final castedReference = reference.withConverter>( @@ -262,9 +262,9 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; transaction.set(reference, json, options); @@ -280,9 +280,9 @@ class _$PersonDocumentReference final json = { ...model.toJson(), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; batch.set(reference, json, options); @@ -304,15 +304,15 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: + _$PersonPerFieldToJson.firstName(firstName as String), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: + _$PersonPerFieldToJson.lastName(lastName as String), if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; return reference.update(json); @@ -335,15 +335,15 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: + _$PersonPerFieldToJson.firstName(firstName as String), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: + _$PersonPerFieldToJson.lastName(lastName as String), if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; transaction.update(reference, json); @@ -366,15 +366,15 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$$PersonImplFieldMap['firstName']!: - _$$PersonImplPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: + _$PersonPerFieldToJson.firstName(firstName as String), if (firstNameFieldValue != null) - _$$PersonImplFieldMap['firstName']!: firstNameFieldValue, + _$PersonFieldMap['firstName']!: firstNameFieldValue, if (lastName != _sentinel) - _$$PersonImplFieldMap['lastName']!: - _$$PersonImplPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: + _$PersonPerFieldToJson.lastName(lastName as String), if (lastNameFieldValue != null) - _$$PersonImplFieldMap['lastName']!: lastNameFieldValue, + _$PersonFieldMap['lastName']!: lastNameFieldValue, }; batch.update(reference, json); @@ -663,30 +663,27 @@ class _$PersonQuery extends QueryReference return _$PersonQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['firstName']!, + _$PersonFieldMap['firstName']!, isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.firstName(isNotEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.firstName(isLessThan as String) + ? _$PersonPerFieldToJson.firstName(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isLessThanOrEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.firstName(isGreaterThan as String) + ? _$PersonPerFieldToJson.firstName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String) + ? _$PersonPerFieldToJson.firstName(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.firstName(e)), + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), isNull: isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), @@ -710,30 +707,27 @@ class _$PersonQuery extends QueryReference return _$PersonQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PersonImplFieldMap['lastName']!, + _$PersonFieldMap['lastName']!, isEqualTo: isEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PersonImplPerFieldToJson.lastName(isNotEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PersonImplPerFieldToJson.lastName(isLessThan as String) + ? _$PersonPerFieldToJson.lastName(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isLessThanOrEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PersonImplPerFieldToJson.lastName(isGreaterThan as String) + ? _$PersonPerFieldToJson.lastName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PersonImplPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String) + ? _$PersonPerFieldToJson.lastName(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PersonImplPerFieldToJson.lastName(e)), + whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), + whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), isNull: isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), @@ -902,7 +896,7 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['firstName']!, descending: descending); + .orderBy(_$PersonFieldMap['firstName']!, descending: descending); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -974,8 +968,8 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$$PersonImplFieldMap['lastName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy(_$PersonFieldMap['lastName']!, + descending: descending); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1348,7 +1342,7 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; final castedReference = reference.withConverter>( @@ -1367,7 +1361,7 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; transaction.set(reference, json, options); @@ -1382,7 +1376,7 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< final json = { ...model.toJson(), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; batch.set(reference, json, options); @@ -1398,10 +1392,10 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: + _$PublicRedirected2PerFieldToJson.value(value as String), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; return reference.update(json); @@ -1418,10 +1412,10 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: + _$PublicRedirected2PerFieldToJson.value(value as String), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; transaction.update(reference, json); @@ -1438,10 +1432,10 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$$PublicRedirected2ImplFieldMap['value']!: - _$$PublicRedirected2ImplPerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: + _$PublicRedirected2PerFieldToJson.value(value as String), if (valueFieldValue != null) - _$$PublicRedirected2ImplFieldMap['value']!: valueFieldValue, + _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; batch.update(reference, json); @@ -1711,33 +1705,31 @@ class _$PublicRedirectedQuery return _$PublicRedirectedQuery( _collection, $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PublicRedirected2ImplFieldMap['value']!, + _$PublicRedirected2FieldMap['value']!, isEqualTo: isEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson.value(isEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value(isEqualTo as String) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isNotEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value(isNotEqualTo as String) : null, isLessThan: isLessThan != null - ? _$$PublicRedirected2ImplPerFieldToJson.value(isLessThan as String) + ? _$PublicRedirected2PerFieldToJson.value(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson + ? _$PublicRedirected2PerFieldToJson .value(isLessThanOrEqualTo as String) : null, isGreaterThan: isGreaterThan != null - ? _$$PublicRedirected2ImplPerFieldToJson - .value(isGreaterThan as String) + ? _$PublicRedirected2PerFieldToJson.value(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PublicRedirected2ImplPerFieldToJson + ? _$PublicRedirected2PerFieldToJson .value(isGreaterThanOrEqualTo as String) : null, - whereIn: whereIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), - whereNotIn: whereNotIn - ?.map((e) => _$$PublicRedirected2ImplPerFieldToJson.value(e)), + whereIn: + whereIn?.map((e) => _$PublicRedirected2PerFieldToJson.value(e)), + whereNotIn: + whereNotIn?.map((e) => _$PublicRedirected2PerFieldToJson.value(e)), isNull: isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), @@ -1905,9 +1897,8 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy( - _$$PublicRedirected2ImplFieldMap['value']!, - descending: descending); + final query = $referenceWithoutCursor + .orderBy(_$PublicRedirected2FieldMap['value']!, descending: descending); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2066,52 +2057,990 @@ class PublicRedirectedQueryDocumentSnapshot } } -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** +/// 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 { + factory SimpleFreezedCollectionReference([ + FirebaseFirestore? firestore, + ]) = _$SimpleFreezedCollectionReference; -_$PersonImpl _$$PersonImplFromJson(Map json) => _$PersonImpl( - firstName: json['first_name'] as String, - lastName: json['LAST_NAME'] as String, + static SimpleFreezed fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return SimpleFreezed.fromJson(snapshot.data()!); + } + + static Map toFirestore( + SimpleFreezed value, + SetOptions? options, + ) { + return _$SimpleFreezedToJson(value); + } + + @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, + ), ); + } -const _$$PersonImplFieldMap = { - 'firstName': 'first_name', - 'lastName': 'LAST_NAME', -}; + _$SimpleFreezedCollectionReference._( + CollectionReference reference, + ) : super(reference, $referenceWithoutCursor: reference); -// ignore: unused_element -abstract class _$$PersonImplPerFieldToJson { - // ignore: unused_element - static Object? firstName(String instance) => instance; - // ignore: unused_element - static Object? lastName(String instance) => instance; + 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); } -Map _$$PersonImplToJson(_$PersonImpl instance) => - { +abstract class SimpleFreezedDocumentReference + extends FirestoreDocumentReference { + 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< + SimpleFreezed, + SimpleFreezedDocumentSnapshot> 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 = { + ..._$SimpleFreezedToJson(model), + 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 = { + ..._$SimpleFreezedToJson(model), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + transaction.set(reference, json, options); + } + + void batchSet( + WriteBatch batch, + SimpleFreezed model, { + SetOptions? options, + FieldValue? aFieldValue, + }) { + final json = { + ..._$SimpleFreezedToJson(model), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, + }; + + batch.set(reference, 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, 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 + 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 { + 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); + } +} + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SimpleFreezed _$SimpleFreezedFromJson(Map json) => + SimpleFreezed( + a: (json['a'] as num).toInt(), + ); + +const _$SimpleFreezedFieldMap = { + 'a': 'a', +}; + +// ignore: unused_element +abstract class _$SimpleFreezedPerFieldToJson { + // ignore: unused_element + static Object? a(int instance) => instance; +} + +Map _$SimpleFreezedToJson(SimpleFreezed instance) => + { + 'a': instance.a, + }; + +_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, }; -_$PublicRedirected2Impl _$$PublicRedirected2ImplFromJson( - Map json) => - _$PublicRedirected2Impl( +PublicRedirected2 _$PublicRedirected2FromJson(Map json) => + PublicRedirected2( value: json['value'] as String, ); -const _$$PublicRedirected2ImplFieldMap = { +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) => +Map _$PublicRedirected2ToJson(PublicRedirected2 instance) => { 'value': instance.value, }; 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..f574814 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,25 +2,27 @@ name: cloud_firestore_odm_generator_integration_test publish_to: none environment: - sdk: '>=2.18.0 <4.0.0' + sdk: ">=3.0.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.0 - cloud_firestore_odm: ^1.0.0-dev.85 + cloud_firestore: ^5.0.2 + cloud_firestore_odm: ^1.1.0 flutter: sdk: flutter - freezed_annotation: ^2.2.0 - json_annotation: ^4.8.1 + freezed_annotation: ^3.0.0 + json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: - build_runner: ^2.4.2 + build_runner: ^2.4.8 cloud_firestore_odm_generator: path: ../ flutter_test: sdk: flutter - freezed: ^2.3.2 - json_serializable: '>=6.6.1 <7.0.0' + freezed: ^3.0.2 + json_serializable: ^6.9.4 + test: ^1.25.1 + firebase_core_platform_interface: ^5.0.0 dependency_overrides: cloud_firestore_odm: 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..7970f35 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,13 +2,14 @@ // 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( @@ -49,4 +50,24 @@ void main() { ); }); }); + + /// test freezed mixed mode classes + group('freezed mixed mode classes', () { + test('test freezed simple classes', () { + final 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/setup_firestore_mock.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart index b406e47..9bd0210 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,57 @@ // 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 + bool get isAutomaticDataCollectionEnabled => true; + + @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/src/collection_data.dart b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart index 83ad3ec..8cc9672 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart @@ -196,7 +196,7 @@ represents the content of the collection must be in the same file. .allMethods .firstWhereOrNull((method) => method.name == 'toJson'); final redirectedFreezedClass = redirectedFreezedConstructors - .singleOrNull?.redirectedConstructor!.enclosingElement.name; + .singleOrNull?.redirectedConstructor!.enclosingElement3.name; final generatedJsonTypePrefix = _generatedJsonTypePrefix( hasFreezed: hasFreezed, redirectedFreezedClass: redirectedFreezedClass, @@ -377,7 +377,10 @@ 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'; } @@ -427,7 +430,21 @@ 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 fields; + } + return factoryConstructor.parameters; } else { final uniqueFields = {}; 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..d9811c9 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart @@ -40,7 +40,7 @@ bool isValidatorAnnotation(ElementAnnotation annotation) { final element = annotation.element; if (element == null || element is! ConstructorElement) return false; - return element.enclosingElement.allSupertypes.any((superType) { + return element.enclosingElement3.allSupertypes.any((superType) { return superType.element.name == 'Validator' && superType.element.librarySource.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..0a23742 100644 --- a/packages/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/pubspec.yaml @@ -2,29 +2,29 @@ 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: 1.1.0 environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ">=3.0.0 <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" + analyzer: ">=5.12.0 <8.0.0" + build: ^2.4.1 + build_config: ^1.1.2 + cloud_firestore_odm: ^1.1.0 + collection: ^1.18.0 + freezed_annotation: ^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 + graphs: ^2.3.1 + json_annotation: ^4.9.0 + meta: ^1.12.0 + recase: ^4.1.0 + source_gen: ^2.0.0 source_helper: ^1.3.4 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.4.8 + expect_error: ^1.0.8 + json_serializable: ^6.9.4 + matcher: ^0.12.16 + test: ^1.25.1 From a463de0355c1981eb5793de02171672ca4d1f1e9 Mon Sep 17 00:00:00 2001 From: dorklein Date: Fri, 29 Aug 2025 13:07:25 +0700 Subject: [PATCH 2/8] chore: Update cloud_firestore_odm and generator to version 1.2.0 - Upgrade cloud_firestore dependency to ^6.0.0 - Update pubspec.yaml and CHANGELOG for versioning - Modify transaction and batch methods to remove 'id' field from documents - Enhance testing setup in README for running integration tests - Add new tests for Freezed and other integration scenarios --- README.md | 18 + packages/cloud_firestore_odm/CHANGELOG.md | 3 + .../cloud_firestore_odm_e2e_test.dart | 4 +- .../collection_reference_test.dart | 182 ++--- .../example/integration_test/common.dart | 3 +- .../document_reference_test.dart | 53 +- .../firestore_builder_test.dart | 11 +- .../integration_test/freezed_test.dart | 22 +- .../example/integration_test/path_test.dart | 27 +- .../query_reference_test.dart | 39 +- .../example/lib/integration.g.dart | 104 ++- .../example/lib/integration/enums.g.dart | 112 ++- .../lib/integration/freezed.freezed.dart | 331 ++++++++- .../example/lib/integration/freezed.g.dart | 84 ++- .../lib/integration/named_query.g.dart | 32 +- .../example/lib/integration/query.g.dart | 164 ++++- .../example/lib/movie.g.dart | 223 ++++-- .../cloud_firestore_odm/example/pubspec.yaml | 6 +- .../example/web/index.html | 68 +- packages/cloud_firestore_odm/pubspec.yaml | 6 +- .../CHANGELOG.md | 4 + .../lib/freezed.freezed.dart | 466 +++++++++++- .../lib/freezed.g.dart | 124 +++- .../lib/simple.g.dart | 696 ++++++++++++++---- .../pubspec.yaml | 6 +- .../lib/src/templates/document_reference.dart | 27 +- .../lib/src/templates/query_reference.dart | 35 +- .../pubspec.yaml | 4 +- scripts/run-tests.sh | 22 + 29 files changed, 2247 insertions(+), 629 deletions(-) create mode 100755 scripts/run-tests.sh diff --git a/README.md b/README.md index f7a4df6..c0cf42a 100644 --- a/README.md +++ b/README.md @@ -110,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/packages/cloud_firestore_odm/CHANGELOG.md b/packages/cloud_firestore_odm/CHANGELOG.md index 1ccb554..8b10346 100644 --- a/packages/cloud_firestore_odm/CHANGELOG.md +++ b/packages/cloud_firestore_odm/CHANGELOG.md @@ -1,3 +1,6 @@ +## 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 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..be16607 100644 --- a/packages/cloud_firestore_odm/example/integration_test/common.dart +++ b/packages/cloud_firestore_odm/example/integration_test/common.dart @@ -9,8 +9,7 @@ import 'package:cloud_firestore_odm_example/movie.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:mockito/mockito.dart'; -Future - initializeTest>( +Future initializeTest>( T ref, ) async { final snapshot = await ref.reference.get(); 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..093e409 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 @@ -137,12 +137,8 @@ void main() { await collection.doc('123').get(); expect( - await collection - .doc('123') - .get(const GetOptions(source: Source.cache)), - isA() - .having((e) => e.data?.title, 'data.title', 'title') - .having( + 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, @@ -160,6 +156,8 @@ void main() { (transaction) => collection.doc('123').transactionGet(transaction), ); + print('result.data ${result.data}'); + print('result.data ${result.data}'); expect(result.id, '123'); expect(result.data?.title, 'title'); }); @@ -172,8 +170,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')); @@ -256,9 +253,7 @@ void main() { 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 +281,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, ); }); @@ -420,9 +412,7 @@ void main() { }); 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)); @@ -440,10 +430,7 @@ void main() { 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( @@ -477,10 +464,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 +476,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..19b6a14 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 @@ -58,10 +58,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 +70,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 +87,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 +117,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 +132,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); @@ -171,9 +155,8 @@ void main() { DocumentReferenceQuery(FirebaseFirestore.instance.doc('foo/c')), ); - final snapshot = await ref - .orderByRef(startAt: FirebaseFirestore.instance.doc('foo/b')) - .get(); + final snapshot = + await ref.orderByRef(startAt: FirebaseFirestore.instance.doc('foo/b')).get(); expect(snapshot.docs.length, 2); @@ -217,6 +200,8 @@ void main() { snapshot.docs.map((document) => document.data.number), everyElement(anyOf(1, 2, 3)), ); - }); + }, + skip: + 'FirebaseError: Tried to deserialize key from different project: react-native-firebase-testing vs flutterfire-e2e-tests'); }); } diff --git a/packages/cloud_firestore_odm/example/lib/integration.g.dart b/packages/cloud_firestore_odm/example/lib/integration.g.dart index 71f4646..3ad08ff 100644 --- a/packages/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration.g.dart @@ -272,7 +272,11 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -290,7 +294,11 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -942,25 +950,37 @@ class _$AdvancedJsonQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$AdvancedJsonPerFieldToJson.firstName(startAt as String?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$AdvancedJsonPerFieldToJson.firstName(startAfter as String?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$AdvancedJsonPerFieldToJson.firstName(endAt as String?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$AdvancedJsonPerFieldToJson.firstName(endBefore as String?) + ], endBeforeDocumentSnapshot: null, ); } @@ -1015,25 +1035,37 @@ class _$AdvancedJsonQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$AdvancedJsonPerFieldToJson.lastName(startAt as String?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$AdvancedJsonPerFieldToJson.lastName(startAfter as String?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$AdvancedJsonPerFieldToJson.lastName(endAt as String?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$AdvancedJsonPerFieldToJson.lastName(endBefore as String?) + ], endBeforeDocumentSnapshot: null, ); } @@ -1406,7 +1438,11 @@ class _$_PrivateAdvancedJsonDocumentReference _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1424,7 +1460,11 @@ class _$_PrivateAdvancedJsonDocumentReference _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -2088,25 +2128,37 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PrivateAdvancedJsonPerFieldToJson.firstName(startAt as String?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PrivateAdvancedJsonPerFieldToJson.firstName(startAfter as String?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PrivateAdvancedJsonPerFieldToJson.firstName(endAt as String?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PrivateAdvancedJsonPerFieldToJson.firstName(endBefore as String?) + ], endBeforeDocumentSnapshot: null, ); } @@ -2162,25 +2214,37 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PrivateAdvancedJsonPerFieldToJson.lastName(startAt as String?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PrivateAdvancedJsonPerFieldToJson.lastName(startAfter as String?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PrivateAdvancedJsonPerFieldToJson.lastName(endAt as String?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PrivateAdvancedJsonPerFieldToJson.lastName(endBefore as String?) + ], endBeforeDocumentSnapshot: null, ); } 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..20a9ff6 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart @@ -312,7 +312,11 @@ class _$EnumsDocumentReference _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -338,7 +342,11 @@ class _$EnumsDocumentReference _$EnumsFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1303,25 +1311,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.id(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.id(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.id(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.id(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -1376,25 +1396,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.enumValue(startAt as TestEnum) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.enumValue(startAfter as TestEnum) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.enumValue(endAt as TestEnum) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.enumValue(endBefore as TestEnum) + ], endBeforeDocumentSnapshot: null, ); } @@ -1449,25 +1481,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.nullableEnumValue(startAt as TestEnum?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.nullableEnumValue(startAfter as TestEnum?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.nullableEnumValue(endAt as TestEnum?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.nullableEnumValue(endBefore as TestEnum?) + ], endBeforeDocumentSnapshot: null, ); } @@ -1522,25 +1566,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.enumList(startAt as List) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.enumList(startAfter as List) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.enumList(endAt as List) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.enumList(endBefore as List) + ], endBeforeDocumentSnapshot: null, ); } @@ -1595,25 +1651,37 @@ class _$EnumsQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$EnumsPerFieldToJson.nullableEnumList(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$EnumsPerFieldToJson.nullableEnumList(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$EnumsPerFieldToJson.nullableEnumList(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$EnumsPerFieldToJson.nullableEnumList(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } 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 aa734d6..cbe46b2 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart @@ -1,6 +1,5 @@ -// dart format width=80 -// 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 @@ -97,6 +96,177 @@ class _$PersonCopyWithImpl<$Res> implements $PersonCopyWith<$Res> { } } +/// 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) @@ -268,6 +438,163 @@ class _$PublicRedirectedCopyWithImpl<$Res> } } +/// 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 @JsonSerializable() class PublicRedirected2 implements PublicRedirected { 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 8cbddce..87b2361 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart @@ -269,7 +269,11 @@ class _$PersonDocumentReference _$PersonFieldMap['lastName']!: lastNameFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -287,7 +291,11 @@ class _$PersonDocumentReference _$PersonFieldMap['lastName']!: lastNameFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -928,25 +936,37 @@ class _$PersonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.firstName(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.firstName(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.firstName(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.firstName(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -1001,25 +1021,37 @@ class _$PersonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.lastName(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.lastName(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.lastName(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.lastName(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -1366,7 +1398,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1381,7 +1417,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1930,25 +1970,37 @@ class _$PublicRedirectedQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PublicRedirected2PerFieldToJson.value(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PublicRedirected2PerFieldToJson.value(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PublicRedirected2PerFieldToJson.value(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PublicRedirected2PerFieldToJson.value(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } 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..c5dee3e 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 @@ -273,7 +273,11 @@ class _$ConflictDocumentReference _$ConflictFieldMap['number']!: numberFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -288,7 +292,11 @@ class _$ConflictDocumentReference _$ConflictFieldMap['number']!: numberFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -830,25 +838,37 @@ class _$ConflictQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$ConflictPerFieldToJson.number(startAt as num) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$ConflictPerFieldToJson.number(startAfter as num) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$ConflictPerFieldToJson.number(endAt as num) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$ConflictPerFieldToJson.number(endBefore as num) + ], endBeforeDocumentSnapshot: null, ); } 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..df80fe6 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/query.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/query.g.dart @@ -260,7 +260,11 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< _$DurationQueryFieldMap['duration']!: durationFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -275,7 +279,11 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< _$DurationQueryFieldMap['duration']!: durationFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -823,25 +831,37 @@ class _$DurationQueryQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$DurationQueryPerFieldToJson.duration(startAt as Duration) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$DurationQueryPerFieldToJson.duration(startAfter as Duration) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$DurationQueryPerFieldToJson.duration(endAt as Duration) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$DurationQueryPerFieldToJson.duration(endBefore as Duration) + ], endBeforeDocumentSnapshot: null, ); } @@ -1190,7 +1210,11 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1205,7 +1229,11 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1753,25 +1781,37 @@ class _$DateTimeQueryQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$DateTimeQueryPerFieldToJson.time(startAt as DateTime) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$DateTimeQueryPerFieldToJson.time(startAfter as DateTime) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$DateTimeQueryPerFieldToJson.time(endAt as DateTime) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$DateTimeQueryPerFieldToJson.time(endBefore as DateTime) + ], endBeforeDocumentSnapshot: null, ); } @@ -2122,7 +2162,11 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< _$TimestampQueryFieldMap['time']!: timeFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -2137,7 +2181,11 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< _$TimestampQueryFieldMap['time']!: timeFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -2685,25 +2733,37 @@ class _$TimestampQueryQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$TimestampQueryPerFieldToJson.time(startAt as Timestamp) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$TimestampQueryPerFieldToJson.time(startAfter as Timestamp) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$TimestampQueryPerFieldToJson.time(endAt as Timestamp) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$TimestampQueryPerFieldToJson.time(endBefore as Timestamp) + ], endBeforeDocumentSnapshot: null, ); } @@ -3055,7 +3115,11 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -3070,7 +3134,11 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -3618,25 +3686,37 @@ class _$GeoPointQueryQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$GeoPointQueryPerFieldToJson.point(startAt as GeoPoint) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$GeoPointQueryPerFieldToJson.point(startAfter as GeoPoint) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$GeoPointQueryPerFieldToJson.point(endAt as GeoPoint) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$GeoPointQueryPerFieldToJson.point(endBefore as GeoPoint) + ], endBeforeDocumentSnapshot: null, ); } @@ -3995,7 +4075,11 @@ class _$DocumentReferenceQueryDocumentReference _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -4010,7 +4094,11 @@ class _$DocumentReferenceQueryDocumentReference _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -4570,25 +4658,41 @@ class _$DocumentReferenceQueryQuery extends QueryReference< if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$DocumentReferenceQueryPerFieldToJson + .ref(startAt as DocumentReference>) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$DocumentReferenceQueryPerFieldToJson + .ref(startAfter as DocumentReference>) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$DocumentReferenceQueryPerFieldToJson + .ref(endAt as DocumentReference>) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$DocumentReferenceQueryPerFieldToJson + .ref(endBefore as DocumentReference>) + ], endBeforeDocumentSnapshot: null, ); } diff --git a/packages/cloud_firestore_odm/example/lib/movie.g.dart b/packages/cloud_firestore_odm/example/lib/movie.g.dart index f12e30a..17aee54 100644 --- a/packages/cloud_firestore_odm/example/lib/movie.g.dart +++ b/packages/cloud_firestore_odm/example/lib/movie.g.dart @@ -323,7 +323,7 @@ class _$MovieDocumentReference final castedReference = reference.withConverter>( fromFirestore: (snapshot, options) => throw UnimplementedError(), - toFirestore: (value, options) => value, + toFirestore: (value, options) => value..remove('id'), ); return castedReference.set(json, options); } @@ -355,7 +355,11 @@ class _$MovieDocumentReference if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value..remove('id'), + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -385,7 +389,11 @@ class _$MovieDocumentReference if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value..remove('id'), + ); + batch.set(castedReference, json, options); } Future update({ @@ -1612,25 +1620,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.poster(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.poster(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.poster(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.poster(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -1685,25 +1705,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.likes(startAt as int) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.likes(startAfter as int) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.likes(endAt as int) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.likes(endBefore as int) + ], endBeforeDocumentSnapshot: null, ); } @@ -1758,25 +1790,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.title(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.title(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.title(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.title(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -1831,25 +1875,34 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.year(startAt as int) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.year(startAfter as int) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [...queryCursor.endAt, _$MoviePerFieldToJson.year(endAt as int)], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.year(endBefore as int) + ], endBeforeDocumentSnapshot: null, ); } @@ -1904,25 +1957,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.runtime(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.runtime(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.runtime(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.runtime(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -1977,25 +2042,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.rated(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.rated(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.rated(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.rated(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -2050,25 +2127,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.genre(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.genre(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.genre(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.genre(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } @@ -2123,25 +2212,37 @@ class _$MovieQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MoviePerFieldToJson.tags(startAt as Set?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MoviePerFieldToJson.tags(startAfter as Set?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MoviePerFieldToJson.tags(endAt as Set?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MoviePerFieldToJson.tags(endBefore as Set?) + ], endBeforeDocumentSnapshot: null, ); } @@ -2514,7 +2615,11 @@ class _$CommentDocumentReference _$CommentFieldMap['message']!: messageFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -2532,7 +2637,11 @@ class _$CommentDocumentReference _$CommentFieldMap['message']!: messageFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -3175,25 +3284,37 @@ class _$CommentQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$CommentPerFieldToJson.authorName(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$CommentPerFieldToJson.authorName(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$CommentPerFieldToJson.authorName(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$CommentPerFieldToJson.authorName(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -3248,25 +3369,37 @@ class _$CommentQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$CommentPerFieldToJson.message(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$CommentPerFieldToJson.message(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$CommentPerFieldToJson.message(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$CommentPerFieldToJson.message(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } diff --git a/packages/cloud_firestore_odm/example/pubspec.yaml b/packages/cloud_firestore_odm/example/pubspec.yaml index a6e669f..d24240e 100644 --- a/packages/cloud_firestore_odm/example/pubspec.yaml +++ b/packages/cloud_firestore_odm/example/pubspec.yaml @@ -5,9 +5,9 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - cloud_firestore: ^5.6.5 - cloud_firestore_odm: ^1.1.0 - firebase_core: ^3.0.0 + cloud_firestore: ^6.0.0 + cloud_firestore_odm: ^1.2.0 + firebase_core: ^4.0.0 flutter: sdk: flutter freezed_annotation: ^3.0.0 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 84a2941..ad66088 100644 --- a/packages/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/pubspec.yaml @@ -2,7 +2,7 @@ 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.1.0 +version: 1.2.0 false_secrets: - example/** @@ -11,7 +11,7 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.2 + cloud_firestore: ^6.0.0 flutter: sdk: flutter json_annotation: ^4.9.0 @@ -20,4 +20,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - test: ^1.25.1 + test: ^1.25.15 diff --git a/packages/cloud_firestore_odm_generator/CHANGELOG.md b/packages/cloud_firestore_odm_generator/CHANGELOG.md index 34cd24c..ae0f17d 100644 --- a/packages/cloud_firestore_odm_generator/CHANGELOG.md +++ b/packages/cloud_firestore_odm_generator/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.0 +- **FIX**: `set`, `batchSet` and `transacrtionSet` 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 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 661f349..d7f233b 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,6 +1,5 @@ -// dart format width=80 -// 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 @@ -97,6 +96,177 @@ class _$PersonCopyWithImpl<$Res> implements $PersonCopyWith<$Res> { } } +/// 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) @@ -268,6 +438,163 @@ class _$PublicRedirectedCopyWithImpl<$Res> } } +/// 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 @JsonSerializable() class PublicRedirected2 implements PublicRedirected { @@ -409,4 +736,139 @@ class _$SimpleFreezedCopyWithImpl<$Res> } } +/// 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(); + } + } + + /// 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 206181b..85a3fa1 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 @@ -267,7 +267,11 @@ class _$PersonDocumentReference _$PersonFieldMap['lastName']!: lastNameFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -285,7 +289,11 @@ class _$PersonDocumentReference _$PersonFieldMap['lastName']!: lastNameFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -926,25 +934,37 @@ class _$PersonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.firstName(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.firstName(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.firstName(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.firstName(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -999,25 +1019,37 @@ class _$PersonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PersonPerFieldToJson.lastName(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PersonPerFieldToJson.lastName(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PersonPerFieldToJson.lastName(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PersonPerFieldToJson.lastName(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -1364,7 +1396,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1379,7 +1415,11 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1928,25 +1968,37 @@ class _$PublicRedirectedQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$PublicRedirected2PerFieldToJson.value(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$PublicRedirected2PerFieldToJson.value(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$PublicRedirected2PerFieldToJson.value(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$PublicRedirected2PerFieldToJson.value(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -2080,7 +2132,7 @@ abstract class SimpleFreezedCollectionReference SimpleFreezed value, SetOptions? options, ) { - return _$SimpleFreezedToJson(value); + return value.toJson(); } @override @@ -2274,7 +2326,7 @@ class _$SimpleFreezedDocumentReference extends FirestoreDocumentReference< FieldValue? aFieldValue, }) async { final json = { - ..._$SimpleFreezedToJson(model), + ...model.toJson(), if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, }; @@ -2292,11 +2344,15 @@ class _$SimpleFreezedDocumentReference extends FirestoreDocumentReference< FieldValue? aFieldValue, }) { final json = { - ..._$SimpleFreezedToJson(model), + ...model.toJson(), if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -2306,11 +2362,15 @@ class _$SimpleFreezedDocumentReference extends FirestoreDocumentReference< FieldValue? aFieldValue, }) { final json = { - ..._$SimpleFreezedToJson(model), + ...model.toJson(), if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -2852,25 +2912,37 @@ class _$SimpleFreezedQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$SimpleFreezedPerFieldToJson.a(startAt as int) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$SimpleFreezedPerFieldToJson.a(startAfter as int) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$SimpleFreezedPerFieldToJson.a(endAt as int) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$SimpleFreezedPerFieldToJson.a(endBefore as int) + ], endBeforeDocumentSnapshot: null, ); } 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..031de0c 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 @@ -258,7 +258,11 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -273,7 +277,11 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -819,25 +827,37 @@ class _$IgnoredGetterQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$IgnoredGetterPerFieldToJson.value(startAt as int) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$IgnoredGetterPerFieldToJson.value(startAfter as int) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$IgnoredGetterPerFieldToJson.value(endAt as int) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$IgnoredGetterPerFieldToJson.value(endBefore as int) + ], endBeforeDocumentSnapshot: null, ); } @@ -1178,7 +1198,11 @@ class _$ModelDocumentReference if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -1192,7 +1216,11 @@ class _$ModelDocumentReference if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -1725,25 +1753,37 @@ class _$ModelQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$ModelPerFieldToJson.value(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$ModelPerFieldToJson.value(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$ModelPerFieldToJson.value(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$ModelPerFieldToJson.value(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -2261,7 +2301,11 @@ class _$NestedDocumentReference _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -2311,7 +2355,11 @@ class _$NestedDocumentReference _$NestedFieldMap['nullableEnumList']!: nullableEnumListFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -4149,25 +4197,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.value(startAt as Nested?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.value(startAfter as Nested?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.value(endAt as Nested?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.value(endBefore as Nested?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4222,25 +4282,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.simple(startAt as int?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.simple(startAfter as int?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.simple(endAt as int?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.simple(endBefore as int?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4295,25 +4367,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.valueList(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.valueList(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.valueList(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.valueList(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4368,25 +4452,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.boolList(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.boolList(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.boolList(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.boolList(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4441,25 +4537,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.stringList(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.stringList(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.stringList(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.stringList(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4514,25 +4622,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.numList(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.numList(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.numList(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.numList(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4587,25 +4707,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.objectList(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.objectList(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.objectList(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.objectList(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4660,25 +4792,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.dynamicList(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.dynamicList(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.dynamicList(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.dynamicList(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4733,25 +4877,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.boolSet(startAt as Set?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.boolSet(startAfter as Set?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.boolSet(endAt as Set?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.boolSet(endBefore as Set?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4806,25 +4962,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.enumValue(startAt as TestEnum) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.enumValue(startAfter as TestEnum) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.enumValue(endAt as TestEnum) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.enumValue(endBefore as TestEnum) + ], endBeforeDocumentSnapshot: null, ); } @@ -4880,25 +5048,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.nullableEnumValue(startAt as TestEnum?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.nullableEnumValue(startAfter as TestEnum?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.nullableEnumValue(endAt as TestEnum?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.nullableEnumValue(endBefore as TestEnum?) + ], endBeforeDocumentSnapshot: null, ); } @@ -4953,25 +5133,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.enumList(startAt as List) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.enumList(startAfter as List) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.enumList(endAt as List) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.enumList(endBefore as List) + ], endBeforeDocumentSnapshot: null, ); } @@ -5026,25 +5218,37 @@ class _$NestedQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$NestedPerFieldToJson.nullableEnumList(startAt as List?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$NestedPerFieldToJson.nullableEnumList(startAfter as List?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$NestedPerFieldToJson.nullableEnumList(endAt as List?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$NestedPerFieldToJson.nullableEnumList(endBefore as List?) + ], endBeforeDocumentSnapshot: null, ); } @@ -5989,7 +6193,11 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< _$OptionalJsonFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -6004,7 +6212,11 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< _$OptionalJsonFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -6550,25 +6762,37 @@ class _$OptionalJsonQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$OptionalJsonPerFieldToJson.value(startAt as int) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$OptionalJsonPerFieldToJson.value(startAfter as int) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$OptionalJsonPerFieldToJson.value(endAt as int) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$OptionalJsonPerFieldToJson.value(endBefore as int) + ], endBeforeDocumentSnapshot: null, ); } @@ -6911,7 +7135,11 @@ class _$MixedJsonDocumentReference _$MixedJsonFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -6926,7 +7154,11 @@ class _$MixedJsonDocumentReference _$MixedJsonFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -7468,25 +7700,37 @@ class _$MixedJsonQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$MixedJsonPerFieldToJson.value(startAt as int) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$MixedJsonPerFieldToJson.value(startAfter as int) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$MixedJsonPerFieldToJson.value(endAt as int) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$MixedJsonPerFieldToJson.value(endBefore as int) + ], endBeforeDocumentSnapshot: null, ); } @@ -7880,7 +8124,11 @@ class _$RootDocumentReference _$RootFieldMap['nullable']!: nullableFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -7898,7 +8146,11 @@ class _$RootDocumentReference _$RootFieldMap['nullable']!: nullableFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -8538,25 +8790,37 @@ class _$RootQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$RootPerFieldToJson.nonNullable(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$RootPerFieldToJson.nonNullable(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$RootPerFieldToJson.nonNullable(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$RootPerFieldToJson.nonNullable(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -8611,25 +8875,37 @@ class _$RootQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$RootPerFieldToJson.nullable(startAt as int?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$RootPerFieldToJson.nullable(startAfter as int?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$RootPerFieldToJson.nullable(endAt as int?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$RootPerFieldToJson.nullable(endBefore as int?) + ], endBeforeDocumentSnapshot: null, ); } @@ -8999,7 +9275,11 @@ class _$SubDocumentReference _$SubFieldMap['nullable']!: nullableFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -9017,7 +9297,11 @@ class _$SubDocumentReference _$SubFieldMap['nullable']!: nullableFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -9657,25 +9941,37 @@ class _$SubQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$SubPerFieldToJson.nonNullable(startAt as String) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$SubPerFieldToJson.nonNullable(startAfter as String) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$SubPerFieldToJson.nonNullable(endAt as String) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$SubPerFieldToJson.nonNullable(endBefore as String) + ], endBeforeDocumentSnapshot: null, ); } @@ -9730,25 +10026,37 @@ class _$SubQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$SubPerFieldToJson.nullable(startAt as int?) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$SubPerFieldToJson.nullable(startAfter as int?) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$SubPerFieldToJson.nullable(endAt as int?) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$SubPerFieldToJson.nullable(endBefore as int?) + ], endBeforeDocumentSnapshot: null, ); } @@ -10108,7 +10416,11 @@ class _$AsCamelCaseDocumentReference _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -10123,7 +10435,11 @@ class _$AsCamelCaseDocumentReference _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -10669,25 +10985,37 @@ class _$AsCamelCaseQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$AsCamelCasePerFieldToJson.value(startAt as num) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$AsCamelCasePerFieldToJson.value(startAfter as num) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$AsCamelCasePerFieldToJson.value(endAt as num) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$AsCamelCasePerFieldToJson.value(endBefore as num) + ], endBeforeDocumentSnapshot: null, ); } @@ -11053,7 +11381,11 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< _$CustomSubNameFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -11068,7 +11400,11 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< _$CustomSubNameFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -11614,25 +11950,37 @@ class _$CustomSubNameQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$CustomSubNamePerFieldToJson.value(startAt as num) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$CustomSubNamePerFieldToJson.value(startAfter as num) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$CustomSubNamePerFieldToJson.value(endAt as num) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$CustomSubNamePerFieldToJson.value(endBefore as num) + ], endBeforeDocumentSnapshot: null, ); } @@ -12002,7 +12350,11 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -12017,7 +12369,11 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -12568,25 +12924,37 @@ class _$ThisIsACustomPrefixQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$CustomClassPrefixPerFieldToJson.value(startAt as num) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$CustomClassPrefixPerFieldToJson.value(startAfter as num) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$CustomClassPrefixPerFieldToJson.value(endAt as num) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$CustomClassPrefixPerFieldToJson.value(endBefore as num) + ], endBeforeDocumentSnapshot: null, ); } @@ -12945,7 +13313,11 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< _$ExplicitPathFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -12960,7 +13332,11 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< _$ExplicitPathFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -13506,25 +13882,37 @@ class _$ExplicitPathQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$ExplicitPathPerFieldToJson.value(startAt as num) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$ExplicitPathPerFieldToJson.value(startAfter as num) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$ExplicitPathPerFieldToJson.value(endAt as num) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$ExplicitPathPerFieldToJson.value(endBefore as num) + ], endBeforeDocumentSnapshot: null, ); } @@ -13891,7 +14279,11 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -13906,7 +14298,11 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -14453,25 +14849,37 @@ class _$ExplicitSubPathQuery if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$ExplicitSubPathPerFieldToJson.value(startAt as num) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$ExplicitSubPathPerFieldToJson.value(startAfter as num) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$ExplicitSubPathPerFieldToJson.value(endAt as num) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$ExplicitSubPathPerFieldToJson.value(endBefore as num) + ], endBeforeDocumentSnapshot: null, ); } @@ -14816,7 +15224,11 @@ class _$SubClassDocumentReference _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; - transaction.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + transaction.set(castedReference, json, options); } void batchSet( @@ -14831,7 +15243,11 @@ class _$SubClassDocumentReference _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; - batch.set(reference, json, options); + final castedReference = reference.withConverter>( + fromFirestore: (snapshot, options) => throw UnimplementedError(), + toFirestore: (value, options) => value, + ); + batch.set(castedReference, json, options); } Future update({ @@ -15377,25 +15793,37 @@ class _$SubClassQuery extends QueryReference if (startAt != _sentinel) { queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], + startAt: [ + ...queryCursor.startAt, + _$SubClassPerFieldToJson.instanceGetter(startAt as int) + ], startAtDocumentSnapshot: null, ); } if (startAfter != _sentinel) { queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], + startAfter: [ + ...queryCursor.startAfter, + _$SubClassPerFieldToJson.instanceGetter(startAfter as int) + ], startAfterDocumentSnapshot: null, ); } if (endAt != _sentinel) { queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], + endAt: [ + ...queryCursor.endAt, + _$SubClassPerFieldToJson.instanceGetter(endAt as int) + ], endAtDocumentSnapshot: null, ); } if (endBefore != _sentinel) { queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], + endBefore: [ + ...queryCursor.endBefore, + _$SubClassPerFieldToJson.instanceGetter(endBefore as int) + ], endBeforeDocumentSnapshot: null, ); } 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 f574814..c360b38 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 @@ -5,8 +5,8 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - cloud_firestore: ^5.0.2 - cloud_firestore_odm: ^1.1.0 + cloud_firestore: ^6.0.0 + cloud_firestore_odm: ^1.2.0 flutter: sdk: flutter freezed_annotation: ^3.0.0 @@ -22,7 +22,7 @@ dev_dependencies: freezed: ^3.0.2 json_serializable: ^6.9.4 test: ^1.25.1 - firebase_core_platform_interface: ^5.0.0 + firebase_core_platform_interface: ^6.0.0 dependency_overrides: cloud_firestore_odm: 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/pubspec.yaml b/packages/cloud_firestore_odm_generator/pubspec.yaml index 0a23742..caa7ec4 100644 --- a/packages/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/pubspec.yaml @@ -2,7 +2,7 @@ name: cloud_firestore_odm_generator description: A code generator for cloud_firestore_odm. homepage: https://firebase.flutter.dev/docs/firestore/odm repository: https://github.com/firebaseextended/firestoreodm-flutter -version: 1.1.0 +version: 1.2.0 environment: sdk: ">=3.0.0 <4.0.0" @@ -11,7 +11,7 @@ dependencies: analyzer: ">=5.12.0 <8.0.0" build: ^2.4.1 build_config: ^1.1.2 - cloud_firestore_odm: ^1.1.0 + cloud_firestore_odm: ^1.2.0 collection: ^1.18.0 freezed_annotation: ^3.0.0 # Can be removed once this is fixed https://github.com/dart-lang/graphs/issues/86 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 + + + + From dfa4066f37c199959f9e4c1e9915ee57a5b4b024 Mon Sep 17 00:00:00 2001 From: dorklein Date: Fri, 29 Aug 2025 16:06:52 +0700 Subject: [PATCH 3/8] chore: Update SDK constraints and dependencies for cloud_firestore_odm and generator - Upgrade Dart SDK constraints to >=3.8.0 <4.0.0 in pubspec.yaml files - Update dependencies in example and generator packages to latest versions - Modify integration tests and example code for compatibility with updated dependencies - Refactor code for improved readability and maintainability --- .../query_reference_test.dart | 68 +- .../example/lib/integration.g.dart | 525 +-- .../example/lib/integration/enums.g.dart | 358 ++- .../lib/integration/freezed.freezed.dart | 1019 +++--- .../example/lib/integration/freezed.g.dart | 345 +- .../lib/integration/named_query.g.dart | 142 +- .../example/lib/integration/query.g.dart | 893 +++--- .../example/lib/movie.g.dart | 551 ++-- .../cloud_firestore_odm/example/pubspec.yaml | 10 +- packages/cloud_firestore_odm/pubspec.yaml | 2 +- .../lib/freezed.dart | 17 +- .../lib/freezed.freezed.dart | 1363 ++++---- .../lib/freezed.g.dart | 514 +-- .../lib/simple.dart | 32 +- .../lib/simple.g.dart | 2833 +++++++++-------- .../pubspec.yaml | 14 +- .../test/collection_test.dart | 8 +- .../test/setup_firestore_mock.dart | 18 +- .../lib/src/collection_data.dart | 168 +- .../lib/src/collection_generator.dart | 50 +- .../lib/src/parse_generator.dart | 61 +- .../lib/src/validator_generator.dart | 20 +- .../pubspec.yaml | 26 +- 23 files changed, 4567 insertions(+), 4470 deletions(-) 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 19b6a14..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), @@ -145,63 +138,20 @@ 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')).get(); + final snapshot = await ref + .orderByRef(startAt: FirebaseFirestore.instance.doc('foo/b')) + .get(); 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)), - ); - }, - skip: - 'FirebaseError: Tried to deserialize key from different project: react-native-firebase-testing vs flutterfire-e2e-tests'); - }); } diff --git a/packages/cloud_firestore_odm/example/lib/integration.g.dart b/packages/cloud_firestore_odm/example/lib/integration.g.dart index 3ad08ff..d2e9237 100644 --- a/packages/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration.g.dart @@ -26,9 +26,8 @@ abstract class AdvancedJsonCollectionReference implements AdvancedJsonQuery, FirestoreCollectionReference { - factory AdvancedJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$AdvancedJsonCollectionReference; + factory AdvancedJsonCollectionReference([FirebaseFirestore? firestore]) = + _$AdvancedJsonCollectionReference; static AdvancedJson fromFirestore( DocumentSnapshot> snapshot, @@ -61,7 +60,9 @@ class _$AdvancedJsonCollectionReference extends _$AdvancedJsonQuery firestore ??= FirebaseFirestore.instance; return _$AdvancedJsonCollectionReference._( - firestore.collection('firestore-example-app/test/advanced').withConverter( + firestore + .collection('firestore-example-app/test/advanced') + .withConverter( fromFirestore: AdvancedJsonCollectionReference.fromFirestore, toFirestore: AdvancedJsonCollectionReference.toFirestore, ), @@ -84,9 +85,7 @@ class _$AdvancedJsonCollectionReference extends _$AdvancedJsonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return AdvancedJsonDocumentReference( - reference.doc(id), - ); + return AdvancedJsonDocumentReference(reference.doc(id)); } @override @@ -107,11 +106,12 @@ class _$AdvancedJsonCollectionReference extends _$AdvancedJsonQuery int get hashCode => Object.hash(runtimeType, reference); } -abstract class AdvancedJsonDocumentReference extends FirestoreDocumentReference< - AdvancedJson, AdvancedJsonDocumentSnapshot> { +abstract class AdvancedJsonDocumentReference + extends + FirestoreDocumentReference { factory AdvancedJsonDocumentReference( - DocumentReference reference) = - _$AdvancedJsonDocumentReference; + DocumentReference reference, + ) = _$AdvancedJsonDocumentReference; DocumentReference get reference; @@ -208,9 +208,10 @@ abstract class AdvancedJsonDocumentReference extends FirestoreDocumentReference< }); } -class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< - AdvancedJson, - AdvancedJsonDocumentSnapshot> implements AdvancedJsonDocumentReference { +class _$AdvancedJsonDocumentReference + extends + FirestoreDocumentReference + implements AdvancedJsonDocumentReference { _$AdvancedJsonDocumentReference(this.reference); @override @@ -246,6 +247,7 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ...model.toJson(), if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -268,6 +270,7 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ...model.toJson(), if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -290,6 +293,7 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ...model.toJson(), if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -317,13 +321,16 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (firstName != _sentinel) - _$AdvancedJsonFieldMap['firstName']!: - _$AdvancedJsonPerFieldToJson.firstName(firstName as String?), + _$AdvancedJsonFieldMap['firstName']!: _$AdvancedJsonPerFieldToJson + .firstName(firstName as String?), + if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$AdvancedJsonFieldMap['lastName']!: - _$AdvancedJsonPerFieldToJson.lastName(lastName as String?), + _$AdvancedJsonFieldMap['lastName']!: _$AdvancedJsonPerFieldToJson + .lastName(lastName as String?), + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -348,13 +355,16 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (firstName != _sentinel) - _$AdvancedJsonFieldMap['firstName']!: - _$AdvancedJsonPerFieldToJson.firstName(firstName as String?), + _$AdvancedJsonFieldMap['firstName']!: _$AdvancedJsonPerFieldToJson + .firstName(firstName as String?), + if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$AdvancedJsonFieldMap['lastName']!: - _$AdvancedJsonPerFieldToJson.lastName(lastName as String?), + _$AdvancedJsonFieldMap['lastName']!: _$AdvancedJsonPerFieldToJson + .lastName(lastName as String?), + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -379,13 +389,16 @@ class _$AdvancedJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (firstName != _sentinel) - _$AdvancedJsonFieldMap['firstName']!: - _$AdvancedJsonPerFieldToJson.firstName(firstName as String?), + _$AdvancedJsonFieldMap['firstName']!: _$AdvancedJsonPerFieldToJson + .firstName(firstName as String?), + if (firstNameFieldValue != null) _$AdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$AdvancedJsonFieldMap['lastName']!: - _$AdvancedJsonPerFieldToJson.lastName(lastName as String?), + _$AdvancedJsonFieldMap['lastName']!: _$AdvancedJsonPerFieldToJson + .lastName(lastName as String?), + if (lastNameFieldValue != null) _$AdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -559,17 +572,17 @@ class _$AdvancedJsonQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(AdvancedJsonQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + AdvancedJsonQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -626,7 +639,8 @@ class _$AdvancedJsonQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -658,7 +672,8 @@ class _$AdvancedJsonQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -692,20 +707,24 @@ class _$AdvancedJsonQuery ? _$AdvancedJsonPerFieldToJson.firstName(isLessThan as String?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .firstName(isLessThanOrEqualTo as String?) + ? _$AdvancedJsonPerFieldToJson.firstName( + isLessThanOrEqualTo as String?, + ) : null, isGreaterThan: isGreaterThan != null ? _$AdvancedJsonPerFieldToJson.firstName(isGreaterThan as String?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String?) + ? _$AdvancedJsonPerFieldToJson.firstName( + isGreaterThanOrEqualTo as String?, + ) : null, whereIn: whereIn?.map((e) => _$AdvancedJsonPerFieldToJson.firstName(e)), - whereNotIn: - whereNotIn?.map((e) => _$AdvancedJsonPerFieldToJson.firstName(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$AdvancedJsonPerFieldToJson.firstName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -739,20 +758,24 @@ class _$AdvancedJsonQuery ? _$AdvancedJsonPerFieldToJson.lastName(isLessThan as String?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .lastName(isLessThanOrEqualTo as String?) + ? _$AdvancedJsonPerFieldToJson.lastName( + isLessThanOrEqualTo as String?, + ) : null, isGreaterThan: isGreaterThan != null ? _$AdvancedJsonPerFieldToJson.lastName(isGreaterThan as String?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$AdvancedJsonPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String?) + ? _$AdvancedJsonPerFieldToJson.lastName( + isGreaterThanOrEqualTo as String?, + ) : null, whereIn: whereIn?.map((e) => _$AdvancedJsonPerFieldToJson.lastName(e)), - whereNotIn: - whereNotIn?.map((e) => _$AdvancedJsonPerFieldToJson.lastName(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$AdvancedJsonPerFieldToJson.lastName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -773,8 +796,10 @@ class _$AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -846,8 +871,10 @@ class _$AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -919,8 +946,10 @@ class _$AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$AdvancedJsonFieldMap['firstName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$AdvancedJsonFieldMap['firstName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -952,7 +981,7 @@ class _$AdvancedJsonQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$AdvancedJsonPerFieldToJson.firstName(startAt as String?) + _$AdvancedJsonPerFieldToJson.firstName(startAt as String?), ], startAtDocumentSnapshot: null, ); @@ -961,7 +990,7 @@ class _$AdvancedJsonQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$AdvancedJsonPerFieldToJson.firstName(startAfter as String?) + _$AdvancedJsonPerFieldToJson.firstName(startAfter as String?), ], startAfterDocumentSnapshot: null, ); @@ -970,7 +999,7 @@ class _$AdvancedJsonQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$AdvancedJsonPerFieldToJson.firstName(endAt as String?) + _$AdvancedJsonPerFieldToJson.firstName(endAt as String?), ], endAtDocumentSnapshot: null, ); @@ -979,7 +1008,7 @@ class _$AdvancedJsonQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$AdvancedJsonPerFieldToJson.firstName(endBefore as String?) + _$AdvancedJsonPerFieldToJson.firstName(endBefore as String?), ], endBeforeDocumentSnapshot: null, ); @@ -1004,8 +1033,10 @@ class _$AdvancedJsonQuery AdvancedJsonDocumentSnapshot? endBeforeDocument, AdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$AdvancedJsonFieldMap['lastName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$AdvancedJsonFieldMap['lastName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1037,7 +1068,7 @@ class _$AdvancedJsonQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$AdvancedJsonPerFieldToJson.lastName(startAt as String?) + _$AdvancedJsonPerFieldToJson.lastName(startAt as String?), ], startAtDocumentSnapshot: null, ); @@ -1046,7 +1077,7 @@ class _$AdvancedJsonQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$AdvancedJsonPerFieldToJson.lastName(startAfter as String?) + _$AdvancedJsonPerFieldToJson.lastName(startAfter as String?), ], startAfterDocumentSnapshot: null, ); @@ -1055,7 +1086,7 @@ class _$AdvancedJsonQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$AdvancedJsonPerFieldToJson.lastName(endAt as String?) + _$AdvancedJsonPerFieldToJson.lastName(endAt as String?), ], endAtDocumentSnapshot: null, ); @@ -1064,7 +1095,7 @@ class _$AdvancedJsonQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$AdvancedJsonPerFieldToJson.lastName(endBefore as String?) + _$AdvancedJsonPerFieldToJson.lastName(endBefore as String?), ], endBeforeDocumentSnapshot: null, ); @@ -1097,45 +1128,37 @@ class AdvancedJsonDocumentSnapshot @override AdvancedJsonDocumentReference get reference { - return AdvancedJsonDocumentReference( - snapshot.reference, - ); + return AdvancedJsonDocumentReference(snapshot.reference); } @override final AdvancedJson? data; } -class AdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot { - AdvancedJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(AdvancedJsonQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - AdvancedJsonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, AdvancedJsonDocumentSnapshot._); }).toList(); - return AdvancedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return AdvancedJsonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, AdvancedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1179,8 +1202,10 @@ class AdvancedJsonQueryDocumentSnapshot abstract class _PrivateAdvancedJsonCollectionReference implements _PrivateAdvancedJsonQuery, - FirestoreCollectionReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> { + FirestoreCollectionReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQuerySnapshot + > { factory _PrivateAdvancedJsonCollectionReference([ FirebaseFirestore? firestore, ]) = _$_PrivateAdvancedJsonCollectionReference; @@ -1213,8 +1238,9 @@ abstract class _PrivateAdvancedJsonCollectionReference class _$_PrivateAdvancedJsonCollectionReference extends _$_PrivateAdvancedJsonQuery implements _PrivateAdvancedJsonCollectionReference { - factory _$_PrivateAdvancedJsonCollectionReference( - [FirebaseFirestore? firestore]) { + factory _$_PrivateAdvancedJsonCollectionReference([ + FirebaseFirestore? firestore, + ]) { firestore ??= FirebaseFirestore.instance; return _$_PrivateAdvancedJsonCollectionReference._( @@ -1244,14 +1270,13 @@ class _$_PrivateAdvancedJsonCollectionReference id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return _PrivateAdvancedJsonDocumentReference( - reference.doc(id), - ); + return _PrivateAdvancedJsonDocumentReference(reference.doc(id)); } @override Future<_PrivateAdvancedJsonDocumentReference> add( - _PrivateAdvancedJson value) { + _PrivateAdvancedJson value, + ) { return reference .add(value) .then((ref) => _PrivateAdvancedJsonDocumentReference(ref)); @@ -1269,11 +1294,14 @@ class _$_PrivateAdvancedJsonCollectionReference } abstract class _PrivateAdvancedJsonDocumentReference - extends FirestoreDocumentReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonDocumentSnapshot> { + extends + FirestoreDocumentReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonDocumentSnapshot + > { factory _PrivateAdvancedJsonDocumentReference( - DocumentReference<_PrivateAdvancedJson> reference) = - _$_PrivateAdvancedJsonDocumentReference; + DocumentReference<_PrivateAdvancedJson> reference, + ) = _$_PrivateAdvancedJsonDocumentReference; DocumentReference<_PrivateAdvancedJson> get reference; @@ -1371,8 +1399,11 @@ abstract class _PrivateAdvancedJsonDocumentReference } class _$_PrivateAdvancedJsonDocumentReference - extends FirestoreDocumentReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonDocumentSnapshot> + extends + FirestoreDocumentReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonDocumentSnapshot + > implements _PrivateAdvancedJsonDocumentReference { _$_PrivateAdvancedJsonDocumentReference(this.reference); @@ -1396,7 +1427,8 @@ class _$_PrivateAdvancedJsonDocumentReference @override Future<_PrivateAdvancedJsonDocumentSnapshot> transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction .get(reference) .then(_PrivateAdvancedJsonDocumentSnapshot._); @@ -1412,6 +1444,7 @@ class _$_PrivateAdvancedJsonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -1434,6 +1467,7 @@ class _$_PrivateAdvancedJsonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -1456,6 +1490,7 @@ class _$_PrivateAdvancedJsonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PrivateAdvancedJsonFieldMap['lastName']!: lastNameFieldValue, }; @@ -1485,11 +1520,14 @@ class _$_PrivateAdvancedJsonDocumentReference 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, }; @@ -1516,11 +1554,14 @@ class _$_PrivateAdvancedJsonDocumentReference 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, }; @@ -1547,11 +1588,14 @@ class _$_PrivateAdvancedJsonDocumentReference 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, }; @@ -1573,8 +1617,10 @@ class _$_PrivateAdvancedJsonDocumentReference abstract class _PrivateAdvancedJsonQuery implements - QueryReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> { + QueryReference< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQuerySnapshot + > { @override _PrivateAdvancedJsonQuery limit(int limit); @@ -1719,25 +1765,28 @@ abstract class _PrivateAdvancedJsonQuery }); } -class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, - _PrivateAdvancedJsonQuerySnapshot> implements _PrivateAdvancedJsonQuery { +class _$_PrivateAdvancedJsonQuery + extends + QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonQuerySnapshot> + implements _PrivateAdvancedJsonQuery { _$_PrivateAdvancedJsonQuery( this._collection, { required Query<_PrivateAdvancedJson> $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override - Stream<_PrivateAdvancedJsonQuerySnapshot> snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(_PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot); + Stream<_PrivateAdvancedJsonQuerySnapshot> snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + _PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -1794,7 +1843,8 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1826,7 +1876,8 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1851,34 +1902,43 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, $referenceWithoutCursor: $referenceWithoutCursor.where( _$PrivateAdvancedJsonFieldMap['firstName']!, isEqualTo: isEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isEqualTo as String?, + ) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isNotEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isNotEqualTo as String?, + ) : null, isLessThan: isLessThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isLessThan as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isLessThan as String?, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isLessThanOrEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isLessThanOrEqualTo as String?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isGreaterThan as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isGreaterThan as String?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .firstName(isGreaterThanOrEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.firstName( + isGreaterThanOrEqualTo as String?, + ) : null, - whereIn: whereIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e)), - whereNotIn: whereNotIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.firstName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1906,30 +1966,38 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, ? _$PrivateAdvancedJsonPerFieldToJson.lastName(isEqualTo as String?) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isNotEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isNotEqualTo as String?, + ) : null, isLessThan: isLessThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isLessThan as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isLessThan as String?, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isLessThanOrEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isLessThanOrEqualTo as String?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isGreaterThan as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isGreaterThan as String?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$PrivateAdvancedJsonPerFieldToJson - .lastName(isGreaterThanOrEqualTo as String?) + ? _$PrivateAdvancedJsonPerFieldToJson.lastName( + isGreaterThanOrEqualTo as String?, + ) : null, - whereIn: whereIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e)), - whereNotIn: whereNotIn - ?.map((e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PrivateAdvancedJsonPerFieldToJson.lastName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1950,8 +2018,10 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2023,8 +2093,10 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonDocumentSnapshot? endBeforeDocument, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2097,8 +2169,9 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$PrivateAdvancedJsonFieldMap['firstName']!, - descending: descending); + _$PrivateAdvancedJsonFieldMap['firstName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2130,7 +2203,7 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$PrivateAdvancedJsonPerFieldToJson.firstName(startAt as String?) + _$PrivateAdvancedJsonPerFieldToJson.firstName(startAt as String?), ], startAtDocumentSnapshot: null, ); @@ -2139,7 +2212,7 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$PrivateAdvancedJsonPerFieldToJson.firstName(startAfter as String?) + _$PrivateAdvancedJsonPerFieldToJson.firstName(startAfter as String?), ], startAfterDocumentSnapshot: null, ); @@ -2148,7 +2221,7 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$PrivateAdvancedJsonPerFieldToJson.firstName(endAt as String?) + _$PrivateAdvancedJsonPerFieldToJson.firstName(endAt as String?), ], endAtDocumentSnapshot: null, ); @@ -2157,7 +2230,7 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$PrivateAdvancedJsonPerFieldToJson.firstName(endBefore as String?) + _$PrivateAdvancedJsonPerFieldToJson.firstName(endBefore as String?), ], endBeforeDocumentSnapshot: null, ); @@ -2183,8 +2256,9 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, _PrivateAdvancedJsonDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$PrivateAdvancedJsonFieldMap['lastName']!, - descending: descending); + _$PrivateAdvancedJsonFieldMap['lastName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2216,7 +2290,7 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$PrivateAdvancedJsonPerFieldToJson.lastName(startAt as String?) + _$PrivateAdvancedJsonPerFieldToJson.lastName(startAt as String?), ], startAtDocumentSnapshot: null, ); @@ -2225,7 +2299,7 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$PrivateAdvancedJsonPerFieldToJson.lastName(startAfter as String?) + _$PrivateAdvancedJsonPerFieldToJson.lastName(startAfter as String?), ], startAfterDocumentSnapshot: null, ); @@ -2234,7 +2308,7 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$PrivateAdvancedJsonPerFieldToJson.lastName(endAt as String?) + _$PrivateAdvancedJsonPerFieldToJson.lastName(endAt as String?), ], endAtDocumentSnapshot: null, ); @@ -2243,7 +2317,7 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$PrivateAdvancedJsonPerFieldToJson.lastName(endBefore as String?) + _$PrivateAdvancedJsonPerFieldToJson.lastName(endBefore as String?), ], endBeforeDocumentSnapshot: null, ); @@ -2270,24 +2344,26 @@ class _$_PrivateAdvancedJsonQuery extends QueryReference<_PrivateAdvancedJson, class _PrivateAdvancedJsonDocumentSnapshot extends FirestoreDocumentSnapshot<_PrivateAdvancedJson> { _PrivateAdvancedJsonDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final DocumentSnapshot<_PrivateAdvancedJson> snapshot; @override _PrivateAdvancedJsonDocumentReference get reference { - return _PrivateAdvancedJsonDocumentReference( - snapshot.reference, - ); + return _PrivateAdvancedJsonDocumentReference(snapshot.reference); } @override final _PrivateAdvancedJson? data; } -class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< - _PrivateAdvancedJson, _PrivateAdvancedJsonQueryDocumentSnapshot> { +class _PrivateAdvancedJsonQuerySnapshot + extends + FirestoreQuerySnapshot< + _PrivateAdvancedJson, + _PrivateAdvancedJsonQueryDocumentSnapshot + > { _PrivateAdvancedJsonQuerySnapshot._( this.snapshot, this.docs, @@ -2297,8 +2373,9 @@ class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< factory _PrivateAdvancedJsonQuerySnapshot._fromQuerySnapshot( QuerySnapshot<_PrivateAdvancedJson> snapshot, ) { - final docs = - snapshot.docs.map(_PrivateAdvancedJsonQueryDocumentSnapshot._).toList(); + final docs = snapshot.docs + .map(_PrivateAdvancedJsonQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { return _decodeDocumentChange( @@ -2307,18 +2384,14 @@ class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< ); }).toList(); - return _PrivateAdvancedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return _PrivateAdvancedJsonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange<_PrivateAdvancedJsonDocumentSnapshot> - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, _PrivateAdvancedJsonDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange<_PrivateAdvancedJsonDocumentSnapshot>( type: docChange.type, @@ -2335,14 +2408,14 @@ class _PrivateAdvancedJsonQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class _PrivateAdvancedJsonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot<_PrivateAdvancedJson> implements _PrivateAdvancedJsonDocumentSnapshot { _PrivateAdvancedJsonQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot<_PrivateAdvancedJson> snapshot; @@ -2363,9 +2436,8 @@ abstract class EmptyModelCollectionReference implements EmptyModelQuery, FirestoreCollectionReference { - factory EmptyModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EmptyModelCollectionReference; + factory EmptyModelCollectionReference([FirebaseFirestore? firestore]) = + _$EmptyModelCollectionReference; static EmptyModel fromFirestore( DocumentSnapshot> snapshot, @@ -2398,16 +2470,17 @@ class _$EmptyModelCollectionReference extends _$EmptyModelQuery firestore ??= FirebaseFirestore.instance; return _$EmptyModelCollectionReference._( - firestore.collection('firestore-example-app/test/config').withConverter( + firestore + .collection('firestore-example-app/test/config') + .withConverter( fromFirestore: EmptyModelCollectionReference.fromFirestore, toFirestore: EmptyModelCollectionReference.toFirestore, ), ); } - _$EmptyModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$EmptyModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -2421,9 +2494,7 @@ class _$EmptyModelCollectionReference extends _$EmptyModelQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return EmptyModelDocumentReference( - reference.doc(id), - ); + return EmptyModelDocumentReference(reference.doc(id)); } @override @@ -2610,17 +2681,17 @@ class _$EmptyModelQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(EmptyModelQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + EmptyModelQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -2677,7 +2748,8 @@ class _$EmptyModelQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2709,7 +2781,8 @@ class _$EmptyModelQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2730,8 +2803,10 @@ class _$EmptyModelQuery EmptyModelDocumentSnapshot? endBeforeDocument, EmptyModelDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2803,8 +2878,10 @@ class _$EmptyModelQuery EmptyModelDocumentSnapshot? endBeforeDocument, EmptyModelDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2883,22 +2960,17 @@ class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { @override EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference( - snapshot.reference, - ); + return EmptyModelDocumentReference(snapshot.reference); } @override final EmptyModel? data; } -class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot { - EmptyModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class EmptyModelQuerySnapshot + extends + FirestoreQuerySnapshot { + EmptyModelQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory EmptyModelQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -2906,21 +2978,14 @@ class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -2973,9 +3038,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', @@ -3016,8 +3081,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.g.dart b/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart index 20a9ff6..8b303b5 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/enums.g.dart @@ -26,9 +26,8 @@ abstract class EnumsCollectionReference implements EnumsQuery, FirestoreCollectionReference { - factory EnumsCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EnumsCollectionReference; + factory EnumsCollectionReference([FirebaseFirestore? firestore]) = + _$EnumsCollectionReference; static Enums fromFirestore( DocumentSnapshot> snapshot, @@ -37,10 +36,7 @@ abstract class EnumsCollectionReference return Enums.fromJson(snapshot.data()!); } - static Map toFirestore( - Enums value, - SetOptions? options, - ) { + static Map toFirestore(Enums value, SetOptions? options) { return value.toJson(); } @@ -61,16 +57,17 @@ class _$EnumsCollectionReference extends _$EnumsQuery firestore ??= FirebaseFirestore.instance; return _$EnumsCollectionReference._( - firestore.collection('firestore-example-app').withConverter( + firestore + .collection('firestore-example-app') + .withConverter( fromFirestore: EnumsCollectionReference.fromFirestore, toFirestore: EnumsCollectionReference.toFirestore, ), ); } - _$EnumsCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$EnumsCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -84,9 +81,7 @@ class _$EnumsCollectionReference extends _$EnumsQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return EnumsDocumentReference( - reference.doc(id), - ); + return EnumsDocumentReference(reference.doc(id)); } @override @@ -272,12 +267,16 @@ class _$EnumsDocumentReference 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, }; @@ -302,12 +301,16 @@ class _$EnumsDocumentReference 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, }; @@ -332,12 +335,16 @@ class _$EnumsDocumentReference 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, }; @@ -384,25 +391,36 @@ class _$EnumsDocumentReference 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), + _$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), + _$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, }; @@ -446,25 +464,36 @@ class _$EnumsDocumentReference 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), + _$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), + _$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, }; @@ -508,25 +537,36 @@ class _$EnumsDocumentReference 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), + _$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), + _$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, }; @@ -770,9 +810,9 @@ class _$EnumsQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -833,7 +873,8 @@ class _$EnumsQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -865,7 +906,8 @@ class _$EnumsQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -909,7 +951,8 @@ class _$EnumsQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$EnumsPerFieldToJson.id(e)), whereNotIn: whereNotIn?.map((e) => _$EnumsPerFieldToJson.id(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -949,12 +992,14 @@ class _$EnumsQuery extends QueryReference ? _$EnumsPerFieldToJson.enumValue(isGreaterThan as TestEnum) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumValue(isGreaterThanOrEqualTo as TestEnum) + ? _$EnumsPerFieldToJson.enumValue( + isGreaterThanOrEqualTo as TestEnum, + ) : null, whereIn: whereIn?.map((e) => _$EnumsPerFieldToJson.enumValue(e)), whereNotIn: whereNotIn?.map((e) => _$EnumsPerFieldToJson.enumValue(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -988,22 +1033,28 @@ class _$EnumsQuery extends QueryReference ? _$EnumsPerFieldToJson.nullableEnumValue(isLessThan as TestEnum?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isLessThanOrEqualTo as TestEnum?) + ? _$EnumsPerFieldToJson.nullableEnumValue( + isLessThanOrEqualTo as TestEnum?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isGreaterThan as TestEnum?) + ? _$EnumsPerFieldToJson.nullableEnumValue( + isGreaterThan as TestEnum?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumValue(isGreaterThanOrEqualTo as TestEnum?) + ? _$EnumsPerFieldToJson.nullableEnumValue( + isGreaterThanOrEqualTo as TestEnum?, + ) : null, - whereIn: - whereIn?.map((e) => _$EnumsPerFieldToJson.nullableEnumValue(e)), - whereNotIn: - whereNotIn?.map((e) => _$EnumsPerFieldToJson.nullableEnumValue(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$EnumsPerFieldToJson.nullableEnumValue(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$EnumsPerFieldToJson.nullableEnumValue(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1037,26 +1088,29 @@ class _$EnumsQuery extends QueryReference ? _$EnumsPerFieldToJson.enumList(isLessThan as List) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumList(isLessThanOrEqualTo as List) + ? _$EnumsPerFieldToJson.enumList( + isLessThanOrEqualTo as List, + ) : null, isGreaterThan: isGreaterThan != null ? _$EnumsPerFieldToJson.enumList(isGreaterThan as List) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .enumList(isGreaterThanOrEqualTo as List) + ? _$EnumsPerFieldToJson.enumList( + isGreaterThanOrEqualTo as List, + ) : null, arrayContains: arrayContains != null ? (_$EnumsPerFieldToJson.enumList([arrayContains as TestEnum]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$EnumsPerFieldToJson.enumList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1081,39 +1135,48 @@ class _$EnumsQuery extends QueryReference $referenceWithoutCursor: $referenceWithoutCursor.where( _$EnumsFieldMap['nullableEnumList']!, isEqualTo: isEqualTo != _sentinel - ? _$EnumsPerFieldToJson - .nullableEnumList(isEqualTo as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isEqualTo as List?, + ) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$EnumsPerFieldToJson - .nullableEnumList(isNotEqualTo as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isNotEqualTo as List?, + ) : null, isLessThan: isLessThan != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isLessThan as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isLessThan as List?, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isLessThanOrEqualTo as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isGreaterThan as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isGreaterThan as List?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$EnumsPerFieldToJson - .nullableEnumList(isGreaterThanOrEqualTo as List?) + ? _$EnumsPerFieldToJson.nullableEnumList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null - ? (_$EnumsPerFieldToJson - .nullableEnumList([arrayContains as TestEnum]) as List?)! - .single + ? (_$EnumsPerFieldToJson.nullableEnumList([ + arrayContains as TestEnum, + ]) + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$EnumsPerFieldToJson.nullableEnumList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1134,8 +1197,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1207,8 +1272,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1280,8 +1347,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['id']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['id']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1313,7 +1382,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$EnumsPerFieldToJson.id(startAt as String) + _$EnumsPerFieldToJson.id(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1322,7 +1391,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$EnumsPerFieldToJson.id(startAfter as String) + _$EnumsPerFieldToJson.id(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1331,7 +1400,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$EnumsPerFieldToJson.id(endAt as String) + _$EnumsPerFieldToJson.id(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1340,7 +1409,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$EnumsPerFieldToJson.id(endBefore as String) + _$EnumsPerFieldToJson.id(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -1365,8 +1434,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['enumValue']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['enumValue']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1398,7 +1469,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$EnumsPerFieldToJson.enumValue(startAt as TestEnum) + _$EnumsPerFieldToJson.enumValue(startAt as TestEnum), ], startAtDocumentSnapshot: null, ); @@ -1407,7 +1478,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$EnumsPerFieldToJson.enumValue(startAfter as TestEnum) + _$EnumsPerFieldToJson.enumValue(startAfter as TestEnum), ], startAfterDocumentSnapshot: null, ); @@ -1416,7 +1487,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$EnumsPerFieldToJson.enumValue(endAt as TestEnum) + _$EnumsPerFieldToJson.enumValue(endAt as TestEnum), ], endAtDocumentSnapshot: null, ); @@ -1425,7 +1496,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$EnumsPerFieldToJson.enumValue(endBefore as TestEnum) + _$EnumsPerFieldToJson.enumValue(endBefore as TestEnum), ], endBeforeDocumentSnapshot: null, ); @@ -1450,8 +1521,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$EnumsFieldMap['nullableEnumValue']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['nullableEnumValue']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1483,7 +1556,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$EnumsPerFieldToJson.nullableEnumValue(startAt as TestEnum?) + _$EnumsPerFieldToJson.nullableEnumValue(startAt as TestEnum?), ], startAtDocumentSnapshot: null, ); @@ -1492,7 +1565,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$EnumsPerFieldToJson.nullableEnumValue(startAfter as TestEnum?) + _$EnumsPerFieldToJson.nullableEnumValue(startAfter as TestEnum?), ], startAfterDocumentSnapshot: null, ); @@ -1501,7 +1574,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$EnumsPerFieldToJson.nullableEnumValue(endAt as TestEnum?) + _$EnumsPerFieldToJson.nullableEnumValue(endAt as TestEnum?), ], endAtDocumentSnapshot: null, ); @@ -1510,7 +1583,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$EnumsPerFieldToJson.nullableEnumValue(endBefore as TestEnum?) + _$EnumsPerFieldToJson.nullableEnumValue(endBefore as TestEnum?), ], endBeforeDocumentSnapshot: null, ); @@ -1535,8 +1608,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$EnumsFieldMap['enumList']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['enumList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1568,7 +1643,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$EnumsPerFieldToJson.enumList(startAt as List) + _$EnumsPerFieldToJson.enumList(startAt as List), ], startAtDocumentSnapshot: null, ); @@ -1577,7 +1652,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$EnumsPerFieldToJson.enumList(startAfter as List) + _$EnumsPerFieldToJson.enumList(startAfter as List), ], startAfterDocumentSnapshot: null, ); @@ -1586,7 +1661,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$EnumsPerFieldToJson.enumList(endAt as List) + _$EnumsPerFieldToJson.enumList(endAt as List), ], endAtDocumentSnapshot: null, ); @@ -1595,7 +1670,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$EnumsPerFieldToJson.enumList(endBefore as List) + _$EnumsPerFieldToJson.enumList(endBefore as List), ], endBeforeDocumentSnapshot: null, ); @@ -1620,8 +1695,10 @@ class _$EnumsQuery extends QueryReference EnumsDocumentSnapshot? endBeforeDocument, EnumsDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$EnumsFieldMap['nullableEnumList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$EnumsFieldMap['nullableEnumList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1653,7 +1730,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$EnumsPerFieldToJson.nullableEnumList(startAt as List?) + _$EnumsPerFieldToJson.nullableEnumList(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -1662,7 +1739,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$EnumsPerFieldToJson.nullableEnumList(startAfter as List?) + _$EnumsPerFieldToJson.nullableEnumList(startAfter as List?), ], startAfterDocumentSnapshot: null, ); @@ -1671,7 +1748,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$EnumsPerFieldToJson.nullableEnumList(endAt as List?) + _$EnumsPerFieldToJson.nullableEnumList(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -1680,7 +1757,7 @@ class _$EnumsQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$EnumsPerFieldToJson.nullableEnumList(endBefore as List?) + _$EnumsPerFieldToJson.nullableEnumList(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -1712,9 +1789,7 @@ class EnumsDocumentSnapshot extends FirestoreDocumentSnapshot { @override EnumsDocumentReference get reference { - return EnumsDocumentReference( - snapshot.reference, - ); + return EnumsDocumentReference(snapshot.reference); } @override @@ -1723,33 +1798,20 @@ class EnumsDocumentSnapshot extends FirestoreDocumentSnapshot { class EnumsQuerySnapshot extends FirestoreQuerySnapshot { - EnumsQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory EnumsQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + 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._, - ); + return _decodeDocumentChange(change, EnumsDocumentSnapshot._); }).toList(); - return EnumsQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return EnumsQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, EnumsDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1791,19 +1853,22 @@ class EnumsQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot // ************************************************************************** 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', @@ -1831,13 +1896,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.freezed.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart index cbe46b2..268bc1b 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.freezed.dart @@ -14,406 +14,323 @@ 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); + + 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 +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)'; - } +@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> { +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?, - )); - } +/// 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; - } - } +/// 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}); + _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)'; - } +@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}); -} + 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> { +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); +/// 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 + ); } /// @nodoc mixin _$PublicRedirected { - 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); + 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(); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is PublicRedirected && - (identical(other.value, value) || other.value == value)); - } - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, value); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected&&(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)'; - } +@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 +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> { @@ -422,233 +339,197 @@ class _$PublicRedirectedCopyWithImpl<$Res> 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, - )); - } +/// 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; - } - } +/// 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 @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, - ); - } + PublicRedirected2({required this.value}); + factory PublicRedirected2.fromJson(Map json) => _$PublicRedirected2FromJson(json); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is PublicRedirected2 && - (identical(other.value, value) || other.value == value)); - } +@override final String 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. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirected2CopyWith get copyWith => _$PublicRedirected2CopyWithImpl(this, _$identity); - @override - String toString() { - return 'PublicRedirected(value: $value)'; - } +@override +Map toJson() { + return _$PublicRedirected2ToJson(this, ); } -/// @nodoc -abstract mixin class $PublicRedirected2CopyWith<$Res> - implements $PublicRedirectedCopyWith<$Res> { - factory $PublicRedirected2CopyWith( - PublicRedirected2 value, $Res Function(PublicRedirected2) _then) = - _$PublicRedirected2CopyWithImpl; - @override - @useResult - $Res call({String value}); +@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 _$PublicRedirected2CopyWithImpl<$Res> implements $PublicRedirected2CopyWith<$Res> { @@ -657,20 +538,16 @@ class _$PublicRedirected2CopyWithImpl<$Res> 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, - )); - } +/// 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 87b2361..16371f8 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart @@ -26,9 +26,8 @@ abstract class PersonCollectionReference implements PersonQuery, FirestoreCollectionReference { - factory PersonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PersonCollectionReference; + factory PersonCollectionReference([FirebaseFirestore? firestore]) = + _$PersonCollectionReference; static Person fromFirestore( DocumentSnapshot> snapshot, @@ -37,10 +36,7 @@ abstract class PersonCollectionReference return Person.fromJson(snapshot.data()!); } - static Map toFirestore( - Person value, - SetOptions? options, - ) { + static Map toFirestore(Person value, SetOptions? options) { return value.toJson(); } @@ -61,16 +57,17 @@ class _$PersonCollectionReference extends _$PersonQuery firestore ??= FirebaseFirestore.instance; return _$PersonCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: PersonCollectionReference.fromFirestore, toFirestore: PersonCollectionReference.toFirestore, ), ); } - _$PersonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$PersonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -84,9 +81,7 @@ class _$PersonCollectionReference extends _$PersonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return PersonDocumentReference( - reference.doc(id), - ); + return PersonDocumentReference(reference.doc(id)); } @override @@ -243,6 +238,7 @@ class _$PersonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -265,6 +261,7 @@ class _$PersonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -287,6 +284,7 @@ class _$PersonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -314,13 +312,18 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$PersonFieldMap['firstName']!: - _$PersonPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$PersonFieldMap['lastName']!: - _$PersonPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -345,13 +348,18 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$PersonFieldMap['firstName']!: - _$PersonPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$PersonFieldMap['lastName']!: - _$PersonPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -376,13 +384,18 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$PersonFieldMap['firstName']!: - _$PersonPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$PersonFieldMap['lastName']!: - _$PersonPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -555,9 +568,9 @@ class _$PersonQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -618,7 +631,8 @@ class _$PersonQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -650,7 +664,8 @@ class _$PersonQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -694,7 +709,8 @@ class _$PersonQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -738,7 +754,8 @@ class _$PersonQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -759,8 +776,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -832,8 +851,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -905,8 +926,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$PersonFieldMap['firstName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['firstName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -938,7 +961,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$PersonPerFieldToJson.firstName(startAt as String) + _$PersonPerFieldToJson.firstName(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -947,7 +970,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$PersonPerFieldToJson.firstName(startAfter as String) + _$PersonPerFieldToJson.firstName(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -956,7 +979,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$PersonPerFieldToJson.firstName(endAt as String) + _$PersonPerFieldToJson.firstName(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -965,7 +988,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$PersonPerFieldToJson.firstName(endBefore as String) + _$PersonPerFieldToJson.firstName(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -990,8 +1013,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$PersonFieldMap['lastName']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['lastName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1023,7 +1048,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$PersonPerFieldToJson.lastName(startAt as String) + _$PersonPerFieldToJson.lastName(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1032,7 +1057,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$PersonPerFieldToJson.lastName(startAfter as String) + _$PersonPerFieldToJson.lastName(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1041,7 +1066,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$PersonPerFieldToJson.lastName(endAt as String) + _$PersonPerFieldToJson.lastName(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1050,7 +1075,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$PersonPerFieldToJson.lastName(endBefore as String) + _$PersonPerFieldToJson.lastName(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -1082,9 +1107,7 @@ class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { @override PersonDocumentReference get reference { - return PersonDocumentReference( - snapshot.reference, - ); + return PersonDocumentReference(snapshot.reference); } @override @@ -1093,11 +1116,7 @@ class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { class PersonQuerySnapshot extends FirestoreQuerySnapshot { - PersonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + PersonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory PersonQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -1105,21 +1124,14 @@ class PersonQuerySnapshot final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PersonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, PersonDocumentSnapshot._); }).toList(); - return PersonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return PersonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1162,11 +1174,12 @@ class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot abstract class PublicRedirectedCollectionReference implements PublicRedirectedQuery, - FirestoreCollectionReference { - factory PublicRedirectedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PublicRedirectedCollectionReference; + FirestoreCollectionReference< + PublicRedirected, + PublicRedirectedQuerySnapshot + > { + factory PublicRedirectedCollectionReference([FirebaseFirestore? firestore]) = + _$PublicRedirectedCollectionReference; static PublicRedirected fromFirestore( DocumentSnapshot> snapshot, @@ -1195,12 +1208,15 @@ abstract class PublicRedirectedCollectionReference class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery implements PublicRedirectedCollectionReference { - factory _$PublicRedirectedCollectionReference( - [FirebaseFirestore? firestore]) { + factory _$PublicRedirectedCollectionReference([ + FirebaseFirestore? firestore, + ]) { firestore ??= FirebaseFirestore.instance; return _$PublicRedirectedCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: PublicRedirectedCollectionReference.fromFirestore, toFirestore: PublicRedirectedCollectionReference.toFirestore, ), @@ -1223,9 +1239,7 @@ class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return PublicRedirectedDocumentReference( - reference.doc(id), - ); + return PublicRedirectedDocumentReference(reference.doc(id)); } @override @@ -1247,11 +1261,14 @@ class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery } abstract class PublicRedirectedDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > { factory PublicRedirectedDocumentReference( - DocumentReference reference) = - _$PublicRedirectedDocumentReference; + DocumentReference reference, + ) = _$PublicRedirectedDocumentReference; DocumentReference get reference; @@ -1315,10 +1332,7 @@ abstract class PublicRedirectedDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); + Future update({String value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -1339,8 +1353,12 @@ abstract class PublicRedirectedDocumentReference }); } -class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< - PublicRedirected, PublicRedirectedDocumentSnapshot> +class _$PublicRedirectedDocumentReference + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > implements PublicRedirectedDocumentReference { _$PublicRedirectedDocumentReference(this.reference); @@ -1364,7 +1382,8 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); } @@ -1434,8 +1453,9 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$PublicRedirected2FieldMap['value']!: - _$PublicRedirected2PerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; @@ -1454,8 +1474,9 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$PublicRedirected2FieldMap['value']!: - _$PublicRedirected2PerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; @@ -1474,8 +1495,9 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$PublicRedirected2FieldMap['value']!: - _$PublicRedirected2PerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; @@ -1625,17 +1647,17 @@ class _$PublicRedirectedQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(PublicRedirectedQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + PublicRedirectedQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -1692,7 +1714,8 @@ class _$PublicRedirectedQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1724,7 +1747,8 @@ class _$PublicRedirectedQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1758,21 +1782,26 @@ class _$PublicRedirectedQuery ? _$PublicRedirected2PerFieldToJson.value(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$PublicRedirected2PerFieldToJson - .value(isLessThanOrEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value( + isLessThanOrEqualTo as String, + ) : null, isGreaterThan: isGreaterThan != null ? _$PublicRedirected2PerFieldToJson.value(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$PublicRedirected2PerFieldToJson - .value(isGreaterThanOrEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value( + isGreaterThanOrEqualTo as String, + ) : null, - whereIn: - whereIn?.map((e) => _$PublicRedirected2PerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$PublicRedirected2PerFieldToJson.value(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1793,8 +1822,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1866,8 +1897,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1939,8 +1972,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$PublicRedirected2FieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PublicRedirected2FieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1972,7 +2007,7 @@ class _$PublicRedirectedQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$PublicRedirected2PerFieldToJson.value(startAt as String) + _$PublicRedirected2PerFieldToJson.value(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1981,7 +2016,7 @@ class _$PublicRedirectedQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$PublicRedirected2PerFieldToJson.value(startAfter as String) + _$PublicRedirected2PerFieldToJson.value(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1990,7 +2025,7 @@ class _$PublicRedirectedQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$PublicRedirected2PerFieldToJson.value(endAt as String) + _$PublicRedirected2PerFieldToJson.value(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1999,7 +2034,7 @@ class _$PublicRedirectedQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$PublicRedirected2PerFieldToJson.value(endBefore as String) + _$PublicRedirected2PerFieldToJson.value(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -2032,48 +2067,40 @@ class PublicRedirectedDocumentSnapshot @override PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference( - snapshot.reference, - ); + return PublicRedirectedDocumentReference(snapshot.reference); } @override final PublicRedirected? data; } -class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< - PublicRedirected, PublicRedirectedQueryDocumentSnapshot> { - PublicRedirectedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(PublicRedirectedQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PublicRedirectedDocumentSnapshot._, - ); + return _decodeDocumentChange(change, PublicRedirectedDocumentSnapshot._); }).toList(); - return PublicRedirectedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return PublicRedirectedQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange( type: docChange.type, @@ -2090,14 +2117,14 @@ class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class PublicRedirectedQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements PublicRedirectedDocumentSnapshot { PublicRedirectedQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -2116,9 +2143,9 @@ class PublicRedirectedQueryDocumentSnapshot // ************************************************************************** _Person _$PersonFromJson(Map json) => _Person( - 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 _$PersonFieldMap = { 'firstName': 'first_name', @@ -2134,18 +2161,14 @@ abstract class _$PersonPerFieldToJson { } Map _$PersonToJson(_Person instance) => { - 'first_name': instance.firstName, - 'LAST_NAME': instance.lastName, - }; + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; PublicRedirected2 _$PublicRedirected2FromJson(Map json) => - PublicRedirected2( - value: json['value'] as String, - ); + PublicRedirected2(value: json['value'] as String); -const _$PublicRedirected2FieldMap = { - 'value': 'value', -}; +const _$PublicRedirected2FieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$PublicRedirected2PerFieldToJson { @@ -2154,6 +2177,4 @@ abstract class _$PublicRedirected2PerFieldToJson { } Map _$PublicRedirected2ToJson(PublicRedirected2 instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; 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 c5dee3e..1a9d8c0 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 @@ -19,23 +19,6 @@ class _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). @@ -43,9 +26,8 @@ abstract class ConflictCollectionReference implements ConflictQuery, FirestoreCollectionReference { - factory ConflictCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ConflictCollectionReference; + factory ConflictCollectionReference([FirebaseFirestore? firestore]) = + _$ConflictCollectionReference; static Conflict fromFirestore( DocumentSnapshot> snapshot, @@ -54,10 +36,7 @@ abstract class ConflictCollectionReference return _$ConflictFromJson(snapshot.data()!); } - static Map toFirestore( - Conflict value, - SetOptions? options, - ) { + static Map toFirestore(Conflict value, SetOptions? options) { return _$ConflictToJson(value); } @@ -87,9 +66,8 @@ class _$ConflictCollectionReference extends _$ConflictQuery ); } - _$ConflictCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$ConflictCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -103,9 +81,7 @@ class _$ConflictCollectionReference extends _$ConflictQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ConflictDocumentReference( - reference.doc(id), - ); + return ConflictDocumentReference(reference.doc(id)); } @override @@ -191,10 +167,7 @@ abstract class ConflictDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num number, - FieldValue numberFieldValue, - }); + Future update({num number, FieldValue numberFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -208,11 +181,7 @@ abstract class ConflictDocumentReference /// 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, - }); + void batchUpdate(WriteBatch batch, {num number, FieldValue numberFieldValue}); } class _$ConflictDocumentReference @@ -309,8 +278,10 @@ class _$ConflictDocumentReference ); final json = { if (number != _sentinel) - _$ConflictFieldMap['number']!: - _$ConflictPerFieldToJson.number(number as num), + _$ConflictFieldMap['number']!: _$ConflictPerFieldToJson.number( + number as num, + ), + if (numberFieldValue != null) _$ConflictFieldMap['number']!: numberFieldValue, }; @@ -329,8 +300,10 @@ class _$ConflictDocumentReference ); final json = { if (number != _sentinel) - _$ConflictFieldMap['number']!: - _$ConflictPerFieldToJson.number(number as num), + _$ConflictFieldMap['number']!: _$ConflictPerFieldToJson.number( + number as num, + ), + if (numberFieldValue != null) _$ConflictFieldMap['number']!: numberFieldValue, }; @@ -349,8 +322,10 @@ class _$ConflictDocumentReference ); final json = { if (number != _sentinel) - _$ConflictFieldMap['number']!: - _$ConflictPerFieldToJson.number(number as num), + _$ConflictFieldMap['number']!: _$ConflictPerFieldToJson.number( + number as num, + ), + if (numberFieldValue != null) _$ConflictFieldMap['number']!: numberFieldValue, }; @@ -499,9 +474,9 @@ class _$ConflictQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -564,7 +539,8 @@ class _$ConflictQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -596,7 +572,8 @@ class _$ConflictQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -640,7 +617,8 @@ class _$ConflictQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$ConflictPerFieldToJson.number(e)), whereNotIn: whereNotIn?.map((e) => _$ConflictPerFieldToJson.number(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -661,8 +639,10 @@ class _$ConflictQuery extends QueryReference ConflictDocumentSnapshot? endBeforeDocument, ConflictDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -734,8 +714,10 @@ class _$ConflictQuery extends QueryReference ConflictDocumentSnapshot? endBeforeDocument, ConflictDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -807,8 +789,10 @@ class _$ConflictQuery extends QueryReference ConflictDocumentSnapshot? endBeforeDocument, ConflictDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$ConflictFieldMap['number']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$ConflictFieldMap['number']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -840,7 +824,7 @@ class _$ConflictQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$ConflictPerFieldToJson.number(startAt as num) + _$ConflictPerFieldToJson.number(startAt as num), ], startAtDocumentSnapshot: null, ); @@ -849,7 +833,7 @@ class _$ConflictQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$ConflictPerFieldToJson.number(startAfter as num) + _$ConflictPerFieldToJson.number(startAfter as num), ], startAfterDocumentSnapshot: null, ); @@ -858,7 +842,7 @@ class _$ConflictQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$ConflictPerFieldToJson.number(endAt as num) + _$ConflictPerFieldToJson.number(endAt as num), ], endAtDocumentSnapshot: null, ); @@ -867,7 +851,7 @@ class _$ConflictQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$ConflictPerFieldToJson.number(endBefore as num) + _$ConflictPerFieldToJson.number(endBefore as num), ], endBeforeDocumentSnapshot: null, ); @@ -899,9 +883,7 @@ class ConflictDocumentSnapshot extends FirestoreDocumentSnapshot { @override ConflictDocumentReference get reference { - return ConflictDocumentReference( - snapshot.reference, - ); + return ConflictDocumentReference(snapshot.reference); } @override @@ -910,11 +892,7 @@ class ConflictDocumentSnapshot extends FirestoreDocumentSnapshot { class ConflictQuerySnapshot extends FirestoreQuerySnapshot { - ConflictQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + ConflictQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory ConflictQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -922,21 +900,14 @@ class ConflictQuerySnapshot final docs = snapshot.docs.map(ConflictQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ConflictDocumentSnapshot._, - ); + return _decodeDocumentChange(change, ConflictDocumentSnapshot._); }).toList(); - return ConflictQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ConflictQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ConflictDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -978,13 +949,10 @@ class ConflictQueryDocumentSnapshot // 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 { @@ -993,5 +961,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.g.dart b/packages/cloud_firestore_odm/example/lib/integration/query.g.dart index df80fe6..6fee6c7 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/query.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/query.g.dart @@ -25,11 +25,12 @@ const _sentinel = _Sentinel(); abstract class DurationQueryCollectionReference implements DurationQueryQuery, - FirestoreCollectionReference { - factory DurationQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$DurationQueryCollectionReference; + FirestoreCollectionReference< + DurationQuery, + DurationQueryQuerySnapshot + > { + factory DurationQueryCollectionReference([FirebaseFirestore? firestore]) = + _$DurationQueryCollectionReference; static DurationQuery fromFirestore( DocumentSnapshot> snapshot, @@ -62,7 +63,9 @@ class _$DurationQueryCollectionReference extends _$DurationQueryQuery firestore ??= FirebaseFirestore.instance; return _$DurationQueryCollectionReference._( - firestore.collection('firestore-example-app/42/duration').withConverter( + firestore + .collection('firestore-example-app/42/duration') + .withConverter( fromFirestore: DurationQueryCollectionReference.fromFirestore, toFirestore: DurationQueryCollectionReference.toFirestore, ), @@ -85,9 +88,7 @@ class _$DurationQueryCollectionReference extends _$DurationQueryQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return DurationQueryDocumentReference( - reference.doc(id), - ); + return DurationQueryDocumentReference(reference.doc(id)); } @override @@ -109,11 +110,14 @@ class _$DurationQueryCollectionReference extends _$DurationQueryQuery } abstract class DurationQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + DurationQuery, + DurationQueryDocumentSnapshot + > { factory DurationQueryDocumentReference( - DocumentReference reference) = - _$DurationQueryDocumentReference; + DocumentReference reference, + ) = _$DurationQueryDocumentReference; DocumentReference get reference; @@ -177,10 +181,7 @@ abstract class DurationQueryDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - Duration duration, - FieldValue durationFieldValue, - }); + Future update({Duration duration, FieldValue durationFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -201,9 +202,10 @@ abstract class DurationQueryDocumentReference }); } -class _$DurationQueryDocumentReference extends FirestoreDocumentReference< - DurationQuery, - DurationQueryDocumentSnapshot> implements DurationQueryDocumentReference { +class _$DurationQueryDocumentReference + extends + FirestoreDocumentReference + implements DurationQueryDocumentReference { _$DurationQueryDocumentReference(this.reference); @override @@ -226,7 +228,8 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(DurationQueryDocumentSnapshot._); } @@ -296,8 +299,9 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (duration != _sentinel) - _$DurationQueryFieldMap['duration']!: - _$DurationQueryPerFieldToJson.duration(duration as Duration), + _$DurationQueryFieldMap['duration']!: _$DurationQueryPerFieldToJson + .duration(duration as Duration), + if (durationFieldValue != null) _$DurationQueryFieldMap['duration']!: durationFieldValue, }; @@ -316,8 +320,9 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (duration != _sentinel) - _$DurationQueryFieldMap['duration']!: - _$DurationQueryPerFieldToJson.duration(duration as Duration), + _$DurationQueryFieldMap['duration']!: _$DurationQueryPerFieldToJson + .duration(duration as Duration), + if (durationFieldValue != null) _$DurationQueryFieldMap['duration']!: durationFieldValue, }; @@ -336,8 +341,9 @@ class _$DurationQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (duration != _sentinel) - _$DurationQueryFieldMap['duration']!: - _$DurationQueryPerFieldToJson.duration(duration as Duration), + _$DurationQueryFieldMap['duration']!: _$DurationQueryPerFieldToJson + .duration(duration as Duration), + if (durationFieldValue != null) _$DurationQueryFieldMap['duration']!: durationFieldValue, }; @@ -487,17 +493,17 @@ class _$DurationQueryQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(DurationQueryQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + DurationQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -554,7 +560,8 @@ class _$DurationQueryQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -586,7 +593,8 @@ class _$DurationQueryQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -620,20 +628,24 @@ class _$DurationQueryQuery ? _$DurationQueryPerFieldToJson.duration(isLessThan as Duration) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$DurationQueryPerFieldToJson - .duration(isLessThanOrEqualTo as Duration) + ? _$DurationQueryPerFieldToJson.duration( + isLessThanOrEqualTo as Duration, + ) : null, isGreaterThan: isGreaterThan != null ? _$DurationQueryPerFieldToJson.duration(isGreaterThan as Duration) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DurationQueryPerFieldToJson - .duration(isGreaterThanOrEqualTo as Duration) + ? _$DurationQueryPerFieldToJson.duration( + isGreaterThanOrEqualTo as Duration, + ) : null, whereIn: whereIn?.map((e) => _$DurationQueryPerFieldToJson.duration(e)), - whereNotIn: - whereNotIn?.map((e) => _$DurationQueryPerFieldToJson.duration(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$DurationQueryPerFieldToJson.duration(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -654,8 +666,10 @@ class _$DurationQueryQuery DurationQueryDocumentSnapshot? endBeforeDocument, DurationQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -727,8 +741,10 @@ class _$DurationQueryQuery DurationQueryDocumentSnapshot? endBeforeDocument, DurationQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -800,8 +816,10 @@ class _$DurationQueryQuery DurationQueryDocumentSnapshot? endBeforeDocument, DurationQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$DurationQueryFieldMap['duration']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$DurationQueryFieldMap['duration']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -833,7 +851,7 @@ class _$DurationQueryQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$DurationQueryPerFieldToJson.duration(startAt as Duration) + _$DurationQueryPerFieldToJson.duration(startAt as Duration), ], startAtDocumentSnapshot: null, ); @@ -842,7 +860,7 @@ class _$DurationQueryQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$DurationQueryPerFieldToJson.duration(startAfter as Duration) + _$DurationQueryPerFieldToJson.duration(startAfter as Duration), ], startAfterDocumentSnapshot: null, ); @@ -851,7 +869,7 @@ class _$DurationQueryQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$DurationQueryPerFieldToJson.duration(endAt as Duration) + _$DurationQueryPerFieldToJson.duration(endAt as Duration), ], endAtDocumentSnapshot: null, ); @@ -860,7 +878,7 @@ class _$DurationQueryQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$DurationQueryPerFieldToJson.duration(endBefore as Duration) + _$DurationQueryPerFieldToJson.duration(endBefore as Duration), ], endBeforeDocumentSnapshot: null, ); @@ -893,45 +911,37 @@ class DurationQueryDocumentSnapshot @override DurationQueryDocumentReference get reference { - return DurationQueryDocumentReference( - snapshot.reference, - ); + return DurationQueryDocumentReference(snapshot.reference); } @override final DurationQuery? data; } -class DurationQueryQuerySnapshot extends FirestoreQuerySnapshot { - DurationQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(DurationQueryQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - DurationQueryDocumentSnapshot._, - ); + return _decodeDocumentChange(change, DurationQueryDocumentSnapshot._); }).toList(); - return DurationQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return DurationQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, DurationQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -975,11 +985,12 @@ class DurationQueryQueryDocumentSnapshot abstract class DateTimeQueryCollectionReference implements DateTimeQueryQuery, - FirestoreCollectionReference { - factory DateTimeQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$DateTimeQueryCollectionReference; + FirestoreCollectionReference< + DateTimeQuery, + DateTimeQueryQuerySnapshot + > { + factory DateTimeQueryCollectionReference([FirebaseFirestore? firestore]) = + _$DateTimeQueryCollectionReference; static DateTimeQuery fromFirestore( DocumentSnapshot> snapshot, @@ -1012,7 +1023,9 @@ class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery firestore ??= FirebaseFirestore.instance; return _$DateTimeQueryCollectionReference._( - firestore.collection('firestore-example-app/42/date-time').withConverter( + firestore + .collection('firestore-example-app/42/date-time') + .withConverter( fromFirestore: DateTimeQueryCollectionReference.fromFirestore, toFirestore: DateTimeQueryCollectionReference.toFirestore, ), @@ -1035,9 +1048,7 @@ class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return DateTimeQueryDocumentReference( - reference.doc(id), - ); + return DateTimeQueryDocumentReference(reference.doc(id)); } @override @@ -1059,11 +1070,14 @@ class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery } abstract class DateTimeQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + DateTimeQuery, + DateTimeQueryDocumentSnapshot + > { factory DateTimeQueryDocumentReference( - DocumentReference reference) = - _$DateTimeQueryDocumentReference; + DocumentReference reference, + ) = _$DateTimeQueryDocumentReference; DocumentReference get reference; @@ -1127,10 +1141,7 @@ abstract class DateTimeQueryDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - DateTime time, - FieldValue timeFieldValue, - }); + Future update({DateTime time, FieldValue timeFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -1151,9 +1162,10 @@ abstract class DateTimeQueryDocumentReference }); } -class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< - DateTimeQuery, - DateTimeQueryDocumentSnapshot> implements DateTimeQueryDocumentReference { +class _$DateTimeQueryDocumentReference + extends + FirestoreDocumentReference + implements DateTimeQueryDocumentReference { _$DateTimeQueryDocumentReference(this.reference); @override @@ -1176,7 +1188,8 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(DateTimeQueryDocumentSnapshot._); } @@ -1246,8 +1259,10 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$DateTimeQueryFieldMap['time']!: - _$DateTimeQueryPerFieldToJson.time(time as DateTime), + _$DateTimeQueryFieldMap['time']!: _$DateTimeQueryPerFieldToJson.time( + time as DateTime, + ), + if (timeFieldValue != null) _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; @@ -1266,8 +1281,10 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$DateTimeQueryFieldMap['time']!: - _$DateTimeQueryPerFieldToJson.time(time as DateTime), + _$DateTimeQueryFieldMap['time']!: _$DateTimeQueryPerFieldToJson.time( + time as DateTime, + ), + if (timeFieldValue != null) _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; @@ -1286,8 +1303,10 @@ class _$DateTimeQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$DateTimeQueryFieldMap['time']!: - _$DateTimeQueryPerFieldToJson.time(time as DateTime), + _$DateTimeQueryFieldMap['time']!: _$DateTimeQueryPerFieldToJson.time( + time as DateTime, + ), + if (timeFieldValue != null) _$DateTimeQueryFieldMap['time']!: timeFieldValue, }; @@ -1437,17 +1456,17 @@ class _$DateTimeQueryQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(DateTimeQueryQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + DateTimeQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -1504,7 +1523,8 @@ class _$DateTimeQueryQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1536,7 +1556,8 @@ class _$DateTimeQueryQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1570,20 +1591,24 @@ class _$DateTimeQueryQuery ? _$DateTimeQueryPerFieldToJson.time(isLessThan as DateTime) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$DateTimeQueryPerFieldToJson - .time(isLessThanOrEqualTo as DateTime) + ? _$DateTimeQueryPerFieldToJson.time( + isLessThanOrEqualTo as DateTime, + ) : null, isGreaterThan: isGreaterThan != null ? _$DateTimeQueryPerFieldToJson.time(isGreaterThan as DateTime) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DateTimeQueryPerFieldToJson - .time(isGreaterThanOrEqualTo as DateTime) + ? _$DateTimeQueryPerFieldToJson.time( + isGreaterThanOrEqualTo as DateTime, + ) : null, whereIn: whereIn?.map((e) => _$DateTimeQueryPerFieldToJson.time(e)), - whereNotIn: - whereNotIn?.map((e) => _$DateTimeQueryPerFieldToJson.time(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$DateTimeQueryPerFieldToJson.time(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1604,8 +1629,10 @@ class _$DateTimeQueryQuery DateTimeQueryDocumentSnapshot? endBeforeDocument, DateTimeQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1677,8 +1704,10 @@ class _$DateTimeQueryQuery DateTimeQueryDocumentSnapshot? endBeforeDocument, DateTimeQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1750,8 +1779,10 @@ class _$DateTimeQueryQuery DateTimeQueryDocumentSnapshot? endBeforeDocument, DateTimeQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$DateTimeQueryFieldMap['time']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$DateTimeQueryFieldMap['time']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1783,7 +1814,7 @@ class _$DateTimeQueryQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$DateTimeQueryPerFieldToJson.time(startAt as DateTime) + _$DateTimeQueryPerFieldToJson.time(startAt as DateTime), ], startAtDocumentSnapshot: null, ); @@ -1792,7 +1823,7 @@ class _$DateTimeQueryQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$DateTimeQueryPerFieldToJson.time(startAfter as DateTime) + _$DateTimeQueryPerFieldToJson.time(startAfter as DateTime), ], startAfterDocumentSnapshot: null, ); @@ -1801,7 +1832,7 @@ class _$DateTimeQueryQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$DateTimeQueryPerFieldToJson.time(endAt as DateTime) + _$DateTimeQueryPerFieldToJson.time(endAt as DateTime), ], endAtDocumentSnapshot: null, ); @@ -1810,7 +1841,7 @@ class _$DateTimeQueryQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$DateTimeQueryPerFieldToJson.time(endBefore as DateTime) + _$DateTimeQueryPerFieldToJson.time(endBefore as DateTime), ], endBeforeDocumentSnapshot: null, ); @@ -1843,45 +1874,37 @@ class DateTimeQueryDocumentSnapshot @override DateTimeQueryDocumentReference get reference { - return DateTimeQueryDocumentReference( - snapshot.reference, - ); + return DateTimeQueryDocumentReference(snapshot.reference); } @override final DateTimeQuery? data; } -class DateTimeQueryQuerySnapshot extends FirestoreQuerySnapshot { - DateTimeQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(DateTimeQueryQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - DateTimeQueryDocumentSnapshot._, - ); + return _decodeDocumentChange(change, DateTimeQueryDocumentSnapshot._); }).toList(); - return DateTimeQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return DateTimeQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, DateTimeQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1925,11 +1948,12 @@ class DateTimeQueryQueryDocumentSnapshot abstract class TimestampQueryCollectionReference implements TimestampQueryQuery, - FirestoreCollectionReference { - factory TimestampQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$TimestampQueryCollectionReference; + FirestoreCollectionReference< + TimestampQuery, + TimestampQueryQuerySnapshot + > { + factory TimestampQueryCollectionReference([FirebaseFirestore? firestore]) = + _$TimestampQueryCollectionReference; static TimestampQuery fromFirestore( DocumentSnapshot> snapshot, @@ -1987,9 +2011,7 @@ class _$TimestampQueryCollectionReference extends _$TimestampQueryQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return TimestampQueryDocumentReference( - reference.doc(id), - ); + return TimestampQueryDocumentReference(reference.doc(id)); } @override @@ -2011,11 +2033,14 @@ class _$TimestampQueryCollectionReference extends _$TimestampQueryQuery } abstract class TimestampQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + TimestampQuery, + TimestampQueryDocumentSnapshot + > { factory TimestampQueryDocumentReference( - DocumentReference reference) = - _$TimestampQueryDocumentReference; + DocumentReference reference, + ) = _$TimestampQueryDocumentReference; DocumentReference get reference; @@ -2079,10 +2104,7 @@ abstract class TimestampQueryDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - Timestamp time, - FieldValue timeFieldValue, - }); + Future update({Timestamp time, FieldValue timeFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -2103,9 +2125,13 @@ abstract class TimestampQueryDocumentReference }); } -class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< - TimestampQuery, - TimestampQueryDocumentSnapshot> implements TimestampQueryDocumentReference { +class _$TimestampQueryDocumentReference + extends + FirestoreDocumentReference< + TimestampQuery, + TimestampQueryDocumentSnapshot + > + implements TimestampQueryDocumentReference { _$TimestampQueryDocumentReference(this.reference); @override @@ -2128,7 +2154,8 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(TimestampQueryDocumentSnapshot._); } @@ -2198,8 +2225,10 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$TimestampQueryFieldMap['time']!: - _$TimestampQueryPerFieldToJson.time(time as Timestamp), + _$TimestampQueryFieldMap['time']!: _$TimestampQueryPerFieldToJson.time( + time as Timestamp, + ), + if (timeFieldValue != null) _$TimestampQueryFieldMap['time']!: timeFieldValue, }; @@ -2218,8 +2247,10 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$TimestampQueryFieldMap['time']!: - _$TimestampQueryPerFieldToJson.time(time as Timestamp), + _$TimestampQueryFieldMap['time']!: _$TimestampQueryPerFieldToJson.time( + time as Timestamp, + ), + if (timeFieldValue != null) _$TimestampQueryFieldMap['time']!: timeFieldValue, }; @@ -2238,8 +2269,10 @@ class _$TimestampQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (time != _sentinel) - _$TimestampQueryFieldMap['time']!: - _$TimestampQueryPerFieldToJson.time(time as Timestamp), + _$TimestampQueryFieldMap['time']!: _$TimestampQueryPerFieldToJson.time( + time as Timestamp, + ), + if (timeFieldValue != null) _$TimestampQueryFieldMap['time']!: timeFieldValue, }; @@ -2389,17 +2422,17 @@ class _$TimestampQueryQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(TimestampQueryQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + TimestampQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -2456,7 +2489,8 @@ class _$TimestampQueryQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2488,7 +2522,8 @@ class _$TimestampQueryQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2522,20 +2557,24 @@ class _$TimestampQueryQuery ? _$TimestampQueryPerFieldToJson.time(isLessThan as Timestamp) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$TimestampQueryPerFieldToJson - .time(isLessThanOrEqualTo as Timestamp) + ? _$TimestampQueryPerFieldToJson.time( + isLessThanOrEqualTo as Timestamp, + ) : null, isGreaterThan: isGreaterThan != null ? _$TimestampQueryPerFieldToJson.time(isGreaterThan as Timestamp) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$TimestampQueryPerFieldToJson - .time(isGreaterThanOrEqualTo as Timestamp) + ? _$TimestampQueryPerFieldToJson.time( + isGreaterThanOrEqualTo as Timestamp, + ) : null, whereIn: whereIn?.map((e) => _$TimestampQueryPerFieldToJson.time(e)), - whereNotIn: - whereNotIn?.map((e) => _$TimestampQueryPerFieldToJson.time(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$TimestampQueryPerFieldToJson.time(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2556,8 +2595,10 @@ class _$TimestampQueryQuery TimestampQueryDocumentSnapshot? endBeforeDocument, TimestampQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2629,8 +2670,10 @@ class _$TimestampQueryQuery TimestampQueryDocumentSnapshot? endBeforeDocument, TimestampQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2702,8 +2745,10 @@ class _$TimestampQueryQuery TimestampQueryDocumentSnapshot? endBeforeDocument, TimestampQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$TimestampQueryFieldMap['time']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$TimestampQueryFieldMap['time']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2735,7 +2780,7 @@ class _$TimestampQueryQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$TimestampQueryPerFieldToJson.time(startAt as Timestamp) + _$TimestampQueryPerFieldToJson.time(startAt as Timestamp), ], startAtDocumentSnapshot: null, ); @@ -2744,7 +2789,7 @@ class _$TimestampQueryQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$TimestampQueryPerFieldToJson.time(startAfter as Timestamp) + _$TimestampQueryPerFieldToJson.time(startAfter as Timestamp), ], startAfterDocumentSnapshot: null, ); @@ -2753,7 +2798,7 @@ class _$TimestampQueryQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$TimestampQueryPerFieldToJson.time(endAt as Timestamp) + _$TimestampQueryPerFieldToJson.time(endAt as Timestamp), ], endAtDocumentSnapshot: null, ); @@ -2762,7 +2807,7 @@ class _$TimestampQueryQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$TimestampQueryPerFieldToJson.time(endBefore as Timestamp) + _$TimestampQueryPerFieldToJson.time(endBefore as Timestamp), ], endBeforeDocumentSnapshot: null, ); @@ -2795,45 +2840,37 @@ class TimestampQueryDocumentSnapshot @override TimestampQueryDocumentReference get reference { - return TimestampQueryDocumentReference( - snapshot.reference, - ); + return TimestampQueryDocumentReference(snapshot.reference); } @override final TimestampQuery? data; } -class TimestampQueryQuerySnapshot extends FirestoreQuerySnapshot { - TimestampQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(TimestampQueryQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - TimestampQueryDocumentSnapshot._, - ); + return _decodeDocumentChange(change, TimestampQueryDocumentSnapshot._); }).toList(); - return TimestampQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return TimestampQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, TimestampQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -2852,7 +2889,7 @@ class TimestampQueryQuerySnapshot extends FirestoreQuerySnapshot> - docChanges; + docChanges; } class TimestampQueryQueryDocumentSnapshot @@ -2878,11 +2915,12 @@ class TimestampQueryQueryDocumentSnapshot abstract class GeoPointQueryCollectionReference implements GeoPointQueryQuery, - FirestoreCollectionReference { - factory GeoPointQueryCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$GeoPointQueryCollectionReference; + FirestoreCollectionReference< + GeoPointQuery, + GeoPointQueryQuerySnapshot + > { + factory GeoPointQueryCollectionReference([FirebaseFirestore? firestore]) = + _$GeoPointQueryCollectionReference; static GeoPointQuery fromFirestore( DocumentSnapshot> snapshot, @@ -2940,9 +2978,7 @@ class _$GeoPointQueryCollectionReference extends _$GeoPointQueryQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return GeoPointQueryDocumentReference( - reference.doc(id), - ); + return GeoPointQueryDocumentReference(reference.doc(id)); } @override @@ -2964,11 +3000,14 @@ class _$GeoPointQueryCollectionReference extends _$GeoPointQueryQuery } abstract class GeoPointQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + GeoPointQuery, + GeoPointQueryDocumentSnapshot + > { factory GeoPointQueryDocumentReference( - DocumentReference reference) = - _$GeoPointQueryDocumentReference; + DocumentReference reference, + ) = _$GeoPointQueryDocumentReference; DocumentReference get reference; @@ -3032,10 +3071,7 @@ abstract class GeoPointQueryDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - GeoPoint point, - FieldValue pointFieldValue, - }); + Future update({GeoPoint point, FieldValue pointFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -3056,9 +3092,10 @@ abstract class GeoPointQueryDocumentReference }); } -class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< - GeoPointQuery, - GeoPointQueryDocumentSnapshot> implements GeoPointQueryDocumentReference { +class _$GeoPointQueryDocumentReference + extends + FirestoreDocumentReference + implements GeoPointQueryDocumentReference { _$GeoPointQueryDocumentReference(this.reference); @override @@ -3081,7 +3118,8 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(GeoPointQueryDocumentSnapshot._); } @@ -3151,8 +3189,10 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (point != _sentinel) - _$GeoPointQueryFieldMap['point']!: - _$GeoPointQueryPerFieldToJson.point(point as GeoPoint), + _$GeoPointQueryFieldMap['point']!: _$GeoPointQueryPerFieldToJson.point( + point as GeoPoint, + ), + if (pointFieldValue != null) _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; @@ -3171,8 +3211,10 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (point != _sentinel) - _$GeoPointQueryFieldMap['point']!: - _$GeoPointQueryPerFieldToJson.point(point as GeoPoint), + _$GeoPointQueryFieldMap['point']!: _$GeoPointQueryPerFieldToJson.point( + point as GeoPoint, + ), + if (pointFieldValue != null) _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; @@ -3191,8 +3233,10 @@ class _$GeoPointQueryDocumentReference extends FirestoreDocumentReference< ); final json = { if (point != _sentinel) - _$GeoPointQueryFieldMap['point']!: - _$GeoPointQueryPerFieldToJson.point(point as GeoPoint), + _$GeoPointQueryFieldMap['point']!: _$GeoPointQueryPerFieldToJson.point( + point as GeoPoint, + ), + if (pointFieldValue != null) _$GeoPointQueryFieldMap['point']!: pointFieldValue, }; @@ -3342,17 +3386,17 @@ class _$GeoPointQueryQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(GeoPointQueryQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + GeoPointQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -3409,7 +3453,8 @@ class _$GeoPointQueryQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3441,7 +3486,8 @@ class _$GeoPointQueryQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3475,20 +3521,24 @@ class _$GeoPointQueryQuery ? _$GeoPointQueryPerFieldToJson.point(isLessThan as GeoPoint) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$GeoPointQueryPerFieldToJson - .point(isLessThanOrEqualTo as GeoPoint) + ? _$GeoPointQueryPerFieldToJson.point( + isLessThanOrEqualTo as GeoPoint, + ) : null, isGreaterThan: isGreaterThan != null ? _$GeoPointQueryPerFieldToJson.point(isGreaterThan as GeoPoint) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$GeoPointQueryPerFieldToJson - .point(isGreaterThanOrEqualTo as GeoPoint) + ? _$GeoPointQueryPerFieldToJson.point( + isGreaterThanOrEqualTo as GeoPoint, + ) : null, whereIn: whereIn?.map((e) => _$GeoPointQueryPerFieldToJson.point(e)), - whereNotIn: - whereNotIn?.map((e) => _$GeoPointQueryPerFieldToJson.point(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$GeoPointQueryPerFieldToJson.point(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3509,8 +3559,10 @@ class _$GeoPointQueryQuery GeoPointQueryDocumentSnapshot? endBeforeDocument, GeoPointQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3582,8 +3634,10 @@ class _$GeoPointQueryQuery GeoPointQueryDocumentSnapshot? endBeforeDocument, GeoPointQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3655,8 +3709,10 @@ class _$GeoPointQueryQuery GeoPointQueryDocumentSnapshot? endBeforeDocument, GeoPointQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$GeoPointQueryFieldMap['point']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$GeoPointQueryFieldMap['point']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3688,7 +3744,7 @@ class _$GeoPointQueryQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$GeoPointQueryPerFieldToJson.point(startAt as GeoPoint) + _$GeoPointQueryPerFieldToJson.point(startAt as GeoPoint), ], startAtDocumentSnapshot: null, ); @@ -3697,7 +3753,7 @@ class _$GeoPointQueryQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$GeoPointQueryPerFieldToJson.point(startAfter as GeoPoint) + _$GeoPointQueryPerFieldToJson.point(startAfter as GeoPoint), ], startAfterDocumentSnapshot: null, ); @@ -3706,7 +3762,7 @@ class _$GeoPointQueryQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$GeoPointQueryPerFieldToJson.point(endAt as GeoPoint) + _$GeoPointQueryPerFieldToJson.point(endAt as GeoPoint), ], endAtDocumentSnapshot: null, ); @@ -3715,7 +3771,7 @@ class _$GeoPointQueryQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$GeoPointQueryPerFieldToJson.point(endBefore as GeoPoint) + _$GeoPointQueryPerFieldToJson.point(endBefore as GeoPoint), ], endBeforeDocumentSnapshot: null, ); @@ -3748,45 +3804,37 @@ class GeoPointQueryDocumentSnapshot @override GeoPointQueryDocumentReference get reference { - return GeoPointQueryDocumentReference( - snapshot.reference, - ); + return GeoPointQueryDocumentReference(snapshot.reference); } @override final GeoPointQuery? data; } -class GeoPointQueryQuerySnapshot extends FirestoreQuerySnapshot { - GeoPointQueryQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(GeoPointQueryQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - GeoPointQueryDocumentSnapshot._, - ); + return _decodeDocumentChange(change, GeoPointQueryDocumentSnapshot._); }).toList(); - return GeoPointQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return GeoPointQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, GeoPointQueryDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -3830,8 +3878,10 @@ class GeoPointQueryQueryDocumentSnapshot abstract class DocumentReferenceQueryCollectionReference implements DocumentReferenceQueryQuery, - FirestoreCollectionReference { + FirestoreCollectionReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > { factory DocumentReferenceQueryCollectionReference([ FirebaseFirestore? firestore, ]) = _$DocumentReferenceQueryCollectionReference; @@ -3859,18 +3909,22 @@ abstract class DocumentReferenceQueryCollectionReference /// Add a new document to this collection with the specified data, /// assigning it a document ID automatically. Future add( - DocumentReferenceQuery value); + DocumentReferenceQuery value, + ); } class _$DocumentReferenceQueryCollectionReference extends _$DocumentReferenceQueryQuery implements DocumentReferenceQueryCollectionReference { - factory _$DocumentReferenceQueryCollectionReference( - [FirebaseFirestore? firestore]) { + factory _$DocumentReferenceQueryCollectionReference([ + FirebaseFirestore? firestore, + ]) { firestore ??= FirebaseFirestore.instance; return _$DocumentReferenceQueryCollectionReference._( - firestore.collection('firestore-example-app/42/doc-ref').withConverter( + firestore + .collection('firestore-example-app/42/doc-ref') + .withConverter( fromFirestore: DocumentReferenceQueryCollectionReference.fromFirestore, toFirestore: DocumentReferenceQueryCollectionReference.toFirestore, @@ -3894,14 +3948,13 @@ class _$DocumentReferenceQueryCollectionReference id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return DocumentReferenceQueryDocumentReference( - reference.doc(id), - ); + return DocumentReferenceQueryDocumentReference(reference.doc(id)); } @override Future add( - DocumentReferenceQuery value) { + DocumentReferenceQuery value, + ) { return reference .add(value) .then((ref) => DocumentReferenceQueryDocumentReference(ref)); @@ -3919,11 +3972,14 @@ class _$DocumentReferenceQueryCollectionReference } abstract class DocumentReferenceQueryDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + DocumentReferenceQuery, + DocumentReferenceQueryDocumentSnapshot + > { factory DocumentReferenceQueryDocumentReference( - DocumentReference reference) = - _$DocumentReferenceQueryDocumentReference; + DocumentReference reference, + ) = _$DocumentReferenceQueryDocumentReference; DocumentReference get reference; @@ -4012,8 +4068,11 @@ abstract class DocumentReferenceQueryDocumentReference } class _$DocumentReferenceQueryDocumentReference - extends FirestoreDocumentReference + extends + FirestoreDocumentReference< + DocumentReferenceQuery, + DocumentReferenceQueryDocumentSnapshot + > implements DocumentReferenceQueryDocumentReference { _$DocumentReferenceQueryDocumentReference(this.reference); @@ -4039,7 +4098,8 @@ class _$DocumentReferenceQueryDocumentReference @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction .get(reference) .then(DocumentReferenceQueryDocumentSnapshot._); @@ -4112,8 +4172,10 @@ class _$DocumentReferenceQueryDocumentReference final json = { if (ref != _sentinel) _$DocumentReferenceQueryFieldMap['ref']!: - _$DocumentReferenceQueryPerFieldToJson - .ref(ref as DocumentReference>), + _$DocumentReferenceQueryPerFieldToJson.ref( + ref as DocumentReference>, + ), + if (refFieldValue != null) _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; @@ -4133,8 +4195,10 @@ class _$DocumentReferenceQueryDocumentReference final json = { if (ref != _sentinel) _$DocumentReferenceQueryFieldMap['ref']!: - _$DocumentReferenceQueryPerFieldToJson - .ref(ref as DocumentReference>), + _$DocumentReferenceQueryPerFieldToJson.ref( + ref as DocumentReference>, + ), + if (refFieldValue != null) _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; @@ -4154,8 +4218,10 @@ class _$DocumentReferenceQueryDocumentReference final json = { if (ref != _sentinel) _$DocumentReferenceQueryFieldMap['ref']!: - _$DocumentReferenceQueryPerFieldToJson - .ref(ref as DocumentReference>), + _$DocumentReferenceQueryPerFieldToJson.ref( + ref as DocumentReference>, + ), + if (refFieldValue != null) _$DocumentReferenceQueryFieldMap['ref']!: refFieldValue, }; @@ -4177,8 +4243,10 @@ class _$DocumentReferenceQueryDocumentReference abstract class DocumentReferenceQueryQuery implements - QueryReference { + QueryReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > { @override DocumentReferenceQueryQuery limit(int limit); @@ -4299,26 +4367,31 @@ abstract class DocumentReferenceQueryQuery }); } -class _$DocumentReferenceQueryQuery extends QueryReference< - DocumentReferenceQuery, DocumentReferenceQueryQuerySnapshot> +class _$DocumentReferenceQueryQuery + extends + QueryReference< + DocumentReferenceQuery, + DocumentReferenceQueryQuerySnapshot + > implements DocumentReferenceQueryQuery { _$DocumentReferenceQueryQuery( this._collection, { required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override - Stream snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot); + Stream snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + DocumentReferenceQueryQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -4375,7 +4448,8 @@ class _$DocumentReferenceQueryQuery extends QueryReference< arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -4407,7 +4481,8 @@ class _$DocumentReferenceQueryQuery extends QueryReference< isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -4432,34 +4507,44 @@ class _$DocumentReferenceQueryQuery extends QueryReference< $referenceWithoutCursor: $referenceWithoutCursor.where( _$DocumentReferenceQueryFieldMap['ref']!, isEqualTo: isEqualTo != _sentinel - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isEqualTo as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isEqualTo as DocumentReference>, + ) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isNotEqualTo as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isNotEqualTo as DocumentReference>, + ) : null, isLessThan: isLessThan != null - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isLessThan as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isLessThan as DocumentReference>, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null ? _$DocumentReferenceQueryPerFieldToJson.ref( - isLessThanOrEqualTo as DocumentReference>) + isLessThanOrEqualTo as DocumentReference>, + ) : null, isGreaterThan: isGreaterThan != null - ? _$DocumentReferenceQueryPerFieldToJson - .ref(isGreaterThan as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isGreaterThan as DocumentReference>, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$DocumentReferenceQueryPerFieldToJson.ref(isGreaterThanOrEqualTo - as DocumentReference>) + ? _$DocumentReferenceQueryPerFieldToJson.ref( + isGreaterThanOrEqualTo + as DocumentReference>, + ) : null, - whereIn: - whereIn?.map((e) => _$DocumentReferenceQueryPerFieldToJson.ref(e)), - whereNotIn: whereNotIn - ?.map((e) => _$DocumentReferenceQueryPerFieldToJson.ref(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$DocumentReferenceQueryPerFieldToJson.ref(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$DocumentReferenceQueryPerFieldToJson.ref(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -4480,8 +4565,10 @@ class _$DocumentReferenceQueryQuery extends QueryReference< DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, DocumentReferenceQueryDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4553,8 +4640,10 @@ class _$DocumentReferenceQueryQuery extends QueryReference< DocumentReferenceQueryDocumentSnapshot? endBeforeDocument, DocumentReferenceQueryDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4627,8 +4716,9 @@ class _$DocumentReferenceQueryQuery extends QueryReference< DocumentReferenceQueryDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$DocumentReferenceQueryFieldMap['ref']!, - descending: descending); + _$DocumentReferenceQueryFieldMap['ref']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4660,8 +4750,9 @@ class _$DocumentReferenceQueryQuery extends QueryReference< queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$DocumentReferenceQueryPerFieldToJson - .ref(startAt as DocumentReference>) + _$DocumentReferenceQueryPerFieldToJson.ref( + startAt as DocumentReference>, + ), ], startAtDocumentSnapshot: null, ); @@ -4670,8 +4761,9 @@ class _$DocumentReferenceQueryQuery extends QueryReference< queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$DocumentReferenceQueryPerFieldToJson - .ref(startAfter as DocumentReference>) + _$DocumentReferenceQueryPerFieldToJson.ref( + startAfter as DocumentReference>, + ), ], startAfterDocumentSnapshot: null, ); @@ -4680,8 +4772,9 @@ class _$DocumentReferenceQueryQuery extends QueryReference< queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$DocumentReferenceQueryPerFieldToJson - .ref(endAt as DocumentReference>) + _$DocumentReferenceQueryPerFieldToJson.ref( + endAt as DocumentReference>, + ), ], endAtDocumentSnapshot: null, ); @@ -4690,8 +4783,9 @@ class _$DocumentReferenceQueryQuery extends QueryReference< queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$DocumentReferenceQueryPerFieldToJson - .ref(endBefore as DocumentReference>) + _$DocumentReferenceQueryPerFieldToJson.ref( + endBefore as DocumentReference>, + ), ], endBeforeDocumentSnapshot: null, ); @@ -4718,24 +4812,26 @@ class _$DocumentReferenceQueryQuery extends QueryReference< class DocumentReferenceQueryDocumentSnapshot extends FirestoreDocumentSnapshot { DocumentReferenceQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final DocumentSnapshot snapshot; @override DocumentReferenceQueryDocumentReference get reference { - return DocumentReferenceQueryDocumentReference( - snapshot.reference, - ); + return DocumentReferenceQueryDocumentReference(snapshot.reference); } @override final DocumentReferenceQuery? data; } -class DocumentReferenceQueryQuerySnapshot extends FirestoreQuerySnapshot< - DocumentReferenceQuery, DocumentReferenceQueryQueryDocumentSnapshot> { +class DocumentReferenceQueryQuerySnapshot + extends + FirestoreQuerySnapshot< + DocumentReferenceQuery, + DocumentReferenceQueryQueryDocumentSnapshot + > { DocumentReferenceQueryQuerySnapshot._( this.snapshot, this.docs, @@ -4756,18 +4852,14 @@ class DocumentReferenceQueryQuerySnapshot extends FirestoreQuerySnapshot< ); }).toList(); - return DocumentReferenceQueryQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return DocumentReferenceQueryQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, DocumentReferenceQueryDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange( type: docChange.type, @@ -4784,14 +4876,14 @@ class DocumentReferenceQueryQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class DocumentReferenceQueryQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements DocumentReferenceQueryDocumentSnapshot { DocumentReferenceQueryQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -4810,13 +4902,9 @@ class DocumentReferenceQueryQueryDocumentSnapshot // ************************************************************************** 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 { @@ -4825,18 +4913,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 { @@ -4855,9 +4939,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 { @@ -4876,9 +4958,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 { @@ -4893,15 +4973,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 { @@ -4911,7 +4990,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.g.dart b/packages/cloud_firestore_odm/example/lib/movie.g.dart index 17aee54..a1b19f3 100644 --- a/packages/cloud_firestore_odm/example/lib/movie.g.dart +++ b/packages/cloud_firestore_odm/example/lib/movie.g.dart @@ -26,9 +26,8 @@ abstract class MovieCollectionReference implements MovieQuery, FirestoreCollectionReference { - factory MovieCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$MovieCollectionReference; + factory MovieCollectionReference([FirebaseFirestore? firestore]) = + _$MovieCollectionReference; static Movie fromFirestore( DocumentSnapshot> snapshot, @@ -37,10 +36,7 @@ abstract class MovieCollectionReference return _$MovieFromJson({'id': snapshot.id, ...?snapshot.data()}); } - static Map toFirestore( - Movie value, - SetOptions? options, - ) { + static Map toFirestore(Movie value, SetOptions? options) { return {..._$MovieToJson(value)}..remove('id'); } @@ -61,16 +57,17 @@ class _$MovieCollectionReference extends _$MovieQuery firestore ??= FirebaseFirestore.instance; return _$MovieCollectionReference._( - firestore.collection('firestore-example-app').withConverter( + firestore + .collection('firestore-example-app') + .withConverter( fromFirestore: MovieCollectionReference.fromFirestore, toFirestore: MovieCollectionReference.toFirestore, ), ); } - _$MovieCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$MovieCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -84,9 +81,7 @@ class _$MovieCollectionReference extends _$MovieQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return MovieDocumentReference( - reference.doc(id), - ); + return MovieDocumentReference(reference.doc(id)); } @override @@ -311,13 +306,20 @@ class _$MovieDocumentReference ..._$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, }; @@ -345,13 +347,20 @@ class _$MovieDocumentReference ..._$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, }; @@ -379,13 +388,20 @@ class _$MovieDocumentReference ..._$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, }; @@ -448,34 +464,53 @@ class _$MovieDocumentReference ); final json = { if (poster != _sentinel) - _$MovieFieldMap['poster']!: - _$MoviePerFieldToJson.poster(poster as String), + _$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), + _$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?), + _$MovieFieldMap['genre']!: _$MoviePerFieldToJson.genre( + genre as List?, + ), + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tags != _sentinel) - _$MovieFieldMap['tags']!: - _$MoviePerFieldToJson.tags(tags as Set?), + _$MovieFieldMap['tags']!: _$MoviePerFieldToJson.tags( + tags as Set?, + ), + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; @@ -535,34 +570,53 @@ class _$MovieDocumentReference ); final json = { if (poster != _sentinel) - _$MovieFieldMap['poster']!: - _$MoviePerFieldToJson.poster(poster as String), + _$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), + _$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?), + _$MovieFieldMap['genre']!: _$MoviePerFieldToJson.genre( + genre as List?, + ), + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tags != _sentinel) - _$MovieFieldMap['tags']!: - _$MoviePerFieldToJson.tags(tags as Set?), + _$MovieFieldMap['tags']!: _$MoviePerFieldToJson.tags( + tags as Set?, + ), + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; @@ -622,34 +676,53 @@ class _$MovieDocumentReference ); final json = { if (poster != _sentinel) - _$MovieFieldMap['poster']!: - _$MoviePerFieldToJson.poster(poster as String), + _$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), + _$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?), + _$MovieFieldMap['genre']!: _$MoviePerFieldToJson.genre( + genre as List?, + ), + if (genreFieldValue != null) _$MovieFieldMap['genre']!: genreFieldValue, + if (tags != _sentinel) - _$MovieFieldMap['tags']!: - _$MoviePerFieldToJson.tags(tags as Set?), + _$MovieFieldMap['tags']!: _$MoviePerFieldToJson.tags( + tags as Set?, + ), + if (tagsFieldValue != null) _$MovieFieldMap['tags']!: tagsFieldValue, }; @@ -964,9 +1037,9 @@ class _$MovieQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -1027,7 +1100,8 @@ class _$MovieQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1059,7 +1133,8 @@ class _$MovieQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1103,7 +1178,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.poster(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.poster(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1147,7 +1223,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.likes(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.likes(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1191,7 +1268,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.title(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.title(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1235,7 +1313,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.year(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.year(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1279,7 +1358,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.runtime(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.runtime(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1323,7 +1403,8 @@ class _$MovieQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MoviePerFieldToJson.rated(e)), whereNotIn: whereNotIn?.map((e) => _$MoviePerFieldToJson.rated(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1363,17 +1444,19 @@ class _$MovieQuery extends QueryReference ? _$MoviePerFieldToJson.genre(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$MoviePerFieldToJson - .genre(isGreaterThanOrEqualTo as List?) + ? _$MoviePerFieldToJson.genre( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$MoviePerFieldToJson.genre([arrayContains as String]) as List?)! - .single + .single : null, arrayContainsAny: arrayContainsAny != null ? _$MoviePerFieldToJson.genre(arrayContainsAny) as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1417,12 +1500,13 @@ class _$MovieQuery extends QueryReference : null, arrayContains: arrayContains != null ? (_$MoviePerFieldToJson.tags({arrayContains as String}) as List?)! - .single + .single : null, arrayContainsAny: arrayContainsAny != null ? _$MoviePerFieldToJson.tags(arrayContainsAny) as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1443,8 +1527,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1516,8 +1602,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1589,8 +1677,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['poster']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['poster']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1622,7 +1712,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MoviePerFieldToJson.poster(startAt as String) + _$MoviePerFieldToJson.poster(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1631,7 +1721,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MoviePerFieldToJson.poster(startAfter as String) + _$MoviePerFieldToJson.poster(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1640,7 +1730,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$MoviePerFieldToJson.poster(endAt as String) + _$MoviePerFieldToJson.poster(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1649,7 +1739,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MoviePerFieldToJson.poster(endBefore as String) + _$MoviePerFieldToJson.poster(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -1674,8 +1764,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['likes']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['likes']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1707,7 +1799,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MoviePerFieldToJson.likes(startAt as int) + _$MoviePerFieldToJson.likes(startAt as int), ], startAtDocumentSnapshot: null, ); @@ -1716,7 +1808,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MoviePerFieldToJson.likes(startAfter as int) + _$MoviePerFieldToJson.likes(startAfter as int), ], startAfterDocumentSnapshot: null, ); @@ -1725,7 +1817,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$MoviePerFieldToJson.likes(endAt as int) + _$MoviePerFieldToJson.likes(endAt as int), ], endAtDocumentSnapshot: null, ); @@ -1734,7 +1826,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MoviePerFieldToJson.likes(endBefore as int) + _$MoviePerFieldToJson.likes(endBefore as int), ], endBeforeDocumentSnapshot: null, ); @@ -1759,8 +1851,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['title']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['title']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1792,7 +1886,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MoviePerFieldToJson.title(startAt as String) + _$MoviePerFieldToJson.title(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1801,7 +1895,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MoviePerFieldToJson.title(startAfter as String) + _$MoviePerFieldToJson.title(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1810,7 +1904,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$MoviePerFieldToJson.title(endAt as String) + _$MoviePerFieldToJson.title(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1819,7 +1913,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MoviePerFieldToJson.title(endBefore as String) + _$MoviePerFieldToJson.title(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -1844,8 +1938,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['year']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['year']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1877,7 +1973,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MoviePerFieldToJson.year(startAt as int) + _$MoviePerFieldToJson.year(startAt as int), ], startAtDocumentSnapshot: null, ); @@ -1886,7 +1982,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MoviePerFieldToJson.year(startAfter as int) + _$MoviePerFieldToJson.year(startAfter as int), ], startAfterDocumentSnapshot: null, ); @@ -1901,7 +1997,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MoviePerFieldToJson.year(endBefore as int) + _$MoviePerFieldToJson.year(endBefore as int), ], endBeforeDocumentSnapshot: null, ); @@ -1926,8 +2022,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['runtime']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['runtime']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1959,7 +2057,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MoviePerFieldToJson.runtime(startAt as String) + _$MoviePerFieldToJson.runtime(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1968,7 +2066,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MoviePerFieldToJson.runtime(startAfter as String) + _$MoviePerFieldToJson.runtime(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1977,7 +2075,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$MoviePerFieldToJson.runtime(endAt as String) + _$MoviePerFieldToJson.runtime(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1986,7 +2084,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MoviePerFieldToJson.runtime(endBefore as String) + _$MoviePerFieldToJson.runtime(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -2011,8 +2109,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['rated']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['rated']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2044,7 +2144,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MoviePerFieldToJson.rated(startAt as String) + _$MoviePerFieldToJson.rated(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -2053,7 +2153,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MoviePerFieldToJson.rated(startAfter as String) + _$MoviePerFieldToJson.rated(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -2062,7 +2162,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$MoviePerFieldToJson.rated(endAt as String) + _$MoviePerFieldToJson.rated(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -2071,7 +2171,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MoviePerFieldToJson.rated(endBefore as String) + _$MoviePerFieldToJson.rated(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -2096,8 +2196,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['genre']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['genre']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2129,7 +2231,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MoviePerFieldToJson.genre(startAt as List?) + _$MoviePerFieldToJson.genre(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -2138,7 +2240,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MoviePerFieldToJson.genre(startAfter as List?) + _$MoviePerFieldToJson.genre(startAfter as List?), ], startAfterDocumentSnapshot: null, ); @@ -2147,7 +2249,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$MoviePerFieldToJson.genre(endAt as List?) + _$MoviePerFieldToJson.genre(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -2156,7 +2258,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MoviePerFieldToJson.genre(endBefore as List?) + _$MoviePerFieldToJson.genre(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -2181,8 +2283,10 @@ class _$MovieQuery extends QueryReference MovieDocumentSnapshot? endBeforeDocument, MovieDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MovieFieldMap['tags']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MovieFieldMap['tags']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2214,7 +2318,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MoviePerFieldToJson.tags(startAt as Set?) + _$MoviePerFieldToJson.tags(startAt as Set?), ], startAtDocumentSnapshot: null, ); @@ -2223,7 +2327,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MoviePerFieldToJson.tags(startAfter as Set?) + _$MoviePerFieldToJson.tags(startAfter as Set?), ], startAfterDocumentSnapshot: null, ); @@ -2232,7 +2336,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$MoviePerFieldToJson.tags(endAt as Set?) + _$MoviePerFieldToJson.tags(endAt as Set?), ], endAtDocumentSnapshot: null, ); @@ -2241,7 +2345,7 @@ class _$MovieQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MoviePerFieldToJson.tags(endBefore as Set?) + _$MoviePerFieldToJson.tags(endBefore as Set?), ], endBeforeDocumentSnapshot: null, ); @@ -2273,9 +2377,7 @@ class MovieDocumentSnapshot extends FirestoreDocumentSnapshot { @override MovieDocumentReference get reference { - return MovieDocumentReference( - snapshot.reference, - ); + return MovieDocumentReference(snapshot.reference); } @override @@ -2284,33 +2386,20 @@ class MovieDocumentSnapshot extends FirestoreDocumentSnapshot { class MovieQuerySnapshot extends FirestoreQuerySnapshot { - MovieQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + MovieQuerySnapshot._(this.snapshot, this.docs, this.docChanges); - factory MovieQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + factory MovieQuerySnapshot._fromQuerySnapshot(QuerySnapshot snapshot) { final docs = snapshot.docs.map(MovieQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - MovieDocumentSnapshot._, - ); + return _decodeDocumentChange(change, MovieDocumentSnapshot._); }).toList(); - return MovieQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return MovieQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, MovieDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -2354,9 +2443,8 @@ abstract class CommentCollectionReference implements CommentQuery, FirestoreCollectionReference { - factory CommentCollectionReference( - DocumentReference parent, - ) = _$CommentCollectionReference; + factory CommentCollectionReference(DocumentReference parent) = + _$CommentCollectionReference; static Comment fromFirestore( DocumentSnapshot> snapshot, @@ -2365,10 +2453,7 @@ abstract class CommentCollectionReference return _$CommentFromJson(snapshot.data()!); } - static Map toFirestore( - Comment value, - SetOptions? options, - ) { + static Map toFirestore(Comment value, SetOptions? options) { return _$CommentToJson(value); } @@ -2388,12 +2473,12 @@ abstract class CommentCollectionReference class _$CommentCollectionReference extends _$CommentQuery implements CommentCollectionReference { - factory _$CommentCollectionReference( - DocumentReference parent, - ) { + factory _$CommentCollectionReference(DocumentReference parent) { return _$CommentCollectionReference._( MovieDocumentReference(parent), - parent.collection('comments').withConverter( + parent + .collection('comments') + .withConverter( fromFirestore: CommentCollectionReference.fromFirestore, toFirestore: CommentCollectionReference.toFirestore, ), @@ -2420,9 +2505,7 @@ class _$CommentCollectionReference extends _$CommentQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return CommentDocumentReference( - reference.doc(id), - ); + return CommentDocumentReference(reference.doc(id)); } @override @@ -2589,6 +2672,7 @@ class _$CommentDocumentReference ..._$CommentToJson(model), if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2611,6 +2695,7 @@ class _$CommentDocumentReference ..._$CommentToJson(model), if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2633,6 +2718,7 @@ class _$CommentDocumentReference ..._$CommentToJson(model), if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2660,13 +2746,18 @@ class _$CommentDocumentReference ); final json = { if (authorName != _sentinel) - _$CommentFieldMap['authorName']!: - _$CommentPerFieldToJson.authorName(authorName as String), + _$CommentFieldMap['authorName']!: _$CommentPerFieldToJson.authorName( + authorName as String, + ), + if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (message != _sentinel) - _$CommentFieldMap['message']!: - _$CommentPerFieldToJson.message(message as String), + _$CommentFieldMap['message']!: _$CommentPerFieldToJson.message( + message as String, + ), + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2691,13 +2782,18 @@ class _$CommentDocumentReference ); final json = { if (authorName != _sentinel) - _$CommentFieldMap['authorName']!: - _$CommentPerFieldToJson.authorName(authorName as String), + _$CommentFieldMap['authorName']!: _$CommentPerFieldToJson.authorName( + authorName as String, + ), + if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (message != _sentinel) - _$CommentFieldMap['message']!: - _$CommentPerFieldToJson.message(message as String), + _$CommentFieldMap['message']!: _$CommentPerFieldToJson.message( + message as String, + ), + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2722,13 +2818,18 @@ class _$CommentDocumentReference ); final json = { if (authorName != _sentinel) - _$CommentFieldMap['authorName']!: - _$CommentPerFieldToJson.authorName(authorName as String), + _$CommentFieldMap['authorName']!: _$CommentPerFieldToJson.authorName( + authorName as String, + ), + if (authorNameFieldValue != null) _$CommentFieldMap['authorName']!: authorNameFieldValue, + if (message != _sentinel) - _$CommentFieldMap['message']!: - _$CommentPerFieldToJson.message(message as String), + _$CommentFieldMap['message']!: _$CommentPerFieldToJson.message( + message as String, + ), + if (messageFieldValue != null) _$CommentFieldMap['message']!: messageFieldValue, }; @@ -2901,9 +3002,9 @@ class _$CommentQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -2964,7 +3065,8 @@ class _$CommentQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2996,7 +3098,8 @@ class _$CommentQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3036,13 +3139,16 @@ class _$CommentQuery extends QueryReference ? _$CommentPerFieldToJson.authorName(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$CommentPerFieldToJson - .authorName(isGreaterThanOrEqualTo as String) + ? _$CommentPerFieldToJson.authorName( + isGreaterThanOrEqualTo as String, + ) : null, whereIn: whereIn?.map((e) => _$CommentPerFieldToJson.authorName(e)), - whereNotIn: - whereNotIn?.map((e) => _$CommentPerFieldToJson.authorName(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$CommentPerFieldToJson.authorName(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3086,7 +3192,8 @@ class _$CommentQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$CommentPerFieldToJson.message(e)), whereNotIn: whereNotIn?.map((e) => _$CommentPerFieldToJson.message(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3107,8 +3214,10 @@ class _$CommentQuery extends QueryReference CommentDocumentSnapshot? endBeforeDocument, CommentDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3180,8 +3289,10 @@ class _$CommentQuery extends QueryReference CommentDocumentSnapshot? endBeforeDocument, CommentDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3253,8 +3364,10 @@ class _$CommentQuery extends QueryReference CommentDocumentSnapshot? endBeforeDocument, CommentDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$CommentFieldMap['authorName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$CommentFieldMap['authorName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3286,7 +3399,7 @@ class _$CommentQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$CommentPerFieldToJson.authorName(startAt as String) + _$CommentPerFieldToJson.authorName(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -3295,7 +3408,7 @@ class _$CommentQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$CommentPerFieldToJson.authorName(startAfter as String) + _$CommentPerFieldToJson.authorName(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -3304,7 +3417,7 @@ class _$CommentQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$CommentPerFieldToJson.authorName(endAt as String) + _$CommentPerFieldToJson.authorName(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -3313,7 +3426,7 @@ class _$CommentQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$CommentPerFieldToJson.authorName(endBefore as String) + _$CommentPerFieldToJson.authorName(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -3338,8 +3451,10 @@ class _$CommentQuery extends QueryReference CommentDocumentSnapshot? endBeforeDocument, CommentDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$CommentFieldMap['message']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$CommentFieldMap['message']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -3371,7 +3486,7 @@ class _$CommentQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$CommentPerFieldToJson.message(startAt as String) + _$CommentPerFieldToJson.message(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -3380,7 +3495,7 @@ class _$CommentQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$CommentPerFieldToJson.message(startAfter as String) + _$CommentPerFieldToJson.message(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -3389,7 +3504,7 @@ class _$CommentQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$CommentPerFieldToJson.message(endAt as String) + _$CommentPerFieldToJson.message(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -3398,7 +3513,7 @@ class _$CommentQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$CommentPerFieldToJson.message(endBefore as String) + _$CommentPerFieldToJson.message(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -3430,9 +3545,7 @@ class CommentDocumentSnapshot extends FirestoreDocumentSnapshot { @override CommentDocumentReference get reference { - return CommentDocumentReference( - snapshot.reference, - ); + return CommentDocumentReference(snapshot.reference); } @override @@ -3441,11 +3554,7 @@ class CommentDocumentSnapshot extends FirestoreDocumentSnapshot { class CommentQuerySnapshot extends FirestoreQuerySnapshot { - CommentQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + CommentQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory CommentQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -3453,21 +3562,14 @@ class CommentQuerySnapshot final docs = snapshot.docs.map(CommentQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - CommentDocumentSnapshot._, - ); + return _decodeDocumentChange(change, CommentDocumentSnapshot._); }).toList(); - return CommentQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return CommentQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, CommentDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -3519,17 +3621,16 @@ void _$assertMovie(Movie instance) { // ************************************************************************** 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', @@ -3566,21 +3667,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', @@ -3596,6 +3697,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 d24240e..729164d 100644 --- a/packages/cloud_firestore_odm/example/pubspec.yaml +++ b/packages/cloud_firestore_odm/example/pubspec.yaml @@ -2,7 +2,7 @@ name: cloud_firestore_odm_example publish_to: none environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" dependencies: cloud_firestore: ^6.0.0 @@ -10,23 +10,23 @@ dependencies: firebase_core: ^4.0.0 flutter: sdk: flutter - freezed_annotation: ^3.0.0 + freezed_annotation: ^3.1.0 json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: - build_runner: ^2.4.2 + build_runner: ^2.7.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: ^3.0.0 + freezed: ^3.2.0 http: ^1.0.0 integration_test: sdk: flutter - json_serializable: ^6.7.0 + json_serializable: ^6.11.0 mockito: ^5.0.0 dependency_overrides: diff --git a/packages/cloud_firestore_odm/pubspec.yaml b/packages/cloud_firestore_odm/pubspec.yaml index ad66088..9a8edd4 100644 --- a/packages/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/pubspec.yaml @@ -8,7 +8,7 @@ false_secrets: - example/** environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" dependencies: cloud_firestore: ^6.0.0 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 e8af1d2..e243b7f 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 @@ -27,25 +27,28 @@ abstract class Person with _$Person { final personRef = PersonCollectionReference(); @Collection('freezed-test') +final publicRedirectedRef = PublicRedirectedCollectionReference(); + @freezed 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 -@Collection('freezed-test') @freezed @JsonSerializable() class SimpleFreezed with _$SimpleFreezed { - SimpleFreezed({required this.a}); - final int a; + const SimpleFreezed({required this.a}); + factory SimpleFreezed.fromJson(Map json) => _$SimpleFreezedFromJson(json); - 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.freezed.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.freezed.dart index d7f233b..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 @@ -14,406 +14,323 @@ 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); + + 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 +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)'; - } +@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> { +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?, - )); - } +/// 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; - } - } +/// 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}); + _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)'; - } +@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}); -} + 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> { +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); +/// 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 + ); } /// @nodoc mixin _$PublicRedirected { - 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); + 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(); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is PublicRedirected && - (identical(other.value, value) || other.value == value)); - } - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, value); +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is PublicRedirected&&(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)'; - } +@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 +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> { @@ -422,233 +339,197 @@ class _$PublicRedirectedCopyWithImpl<$Res> 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, - )); - } +/// 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; - } - } +/// 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 @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, - ); - } + PublicRedirected2({required this.value}); + factory PublicRedirected2.fromJson(Map json) => _$PublicRedirected2FromJson(json); - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is PublicRedirected2 && - (identical(other.value, value) || other.value == value)); - } +@override final String 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. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$PublicRedirected2CopyWith get copyWith => _$PublicRedirected2CopyWithImpl(this, _$identity); - @override - String toString() { - return 'PublicRedirected(value: $value)'; - } +@override +Map toJson() { + return _$PublicRedirected2ToJson(this, ); } -/// @nodoc -abstract mixin class $PublicRedirected2CopyWith<$Res> - implements $PublicRedirectedCopyWith<$Res> { - factory $PublicRedirected2CopyWith( - PublicRedirected2 value, $Res Function(PublicRedirected2) _then) = - _$PublicRedirected2CopyWithImpl; - @override - @useResult - $Res call({String value}); +@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 _$PublicRedirected2CopyWithImpl<$Res> implements $PublicRedirected2CopyWith<$Res> { @@ -657,61 +538,60 @@ class _$PublicRedirected2CopyWithImpl<$Res> 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, - )); - } +/// 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 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)'; - } + + 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)); } -/// @nodoc -abstract mixin class $SimpleFreezedCopyWith<$Res> { - factory $SimpleFreezedCopyWith( - SimpleFreezed value, $Res Function(SimpleFreezed) _then) = - _$SimpleFreezedCopyWithImpl; - @useResult - $Res call({int a}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,a); + +@override +String toString() { + return 'SimpleFreezed(a: $a)'; } + +} + +/// @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> { @@ -720,155 +600,140 @@ class _$SimpleFreezedCopyWithImpl<$Res> 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, - )); - } +/// 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, + )); } +} + + /// 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(); - } - } - - /// 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; - } - } +/// 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(); + +} +} +/// 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 85a3fa1..a3f0e99 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 @@ -24,9 +24,8 @@ abstract class PersonCollectionReference implements PersonQuery, FirestoreCollectionReference { - factory PersonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PersonCollectionReference; + factory PersonCollectionReference([FirebaseFirestore? firestore]) = + _$PersonCollectionReference; static Person fromFirestore( DocumentSnapshot> snapshot, @@ -35,10 +34,7 @@ abstract class PersonCollectionReference return Person.fromJson(snapshot.data()!); } - static Map toFirestore( - Person value, - SetOptions? options, - ) { + static Map toFirestore(Person value, SetOptions? options) { return value.toJson(); } @@ -59,16 +55,17 @@ class _$PersonCollectionReference extends _$PersonQuery firestore ??= FirebaseFirestore.instance; return _$PersonCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: PersonCollectionReference.fromFirestore, toFirestore: PersonCollectionReference.toFirestore, ), ); } - _$PersonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$PersonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -82,9 +79,7 @@ class _$PersonCollectionReference extends _$PersonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return PersonDocumentReference( - reference.doc(id), - ); + return PersonDocumentReference(reference.doc(id)); } @override @@ -241,6 +236,7 @@ class _$PersonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -263,6 +259,7 @@ class _$PersonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -285,6 +282,7 @@ class _$PersonDocumentReference ...model.toJson(), if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -312,13 +310,18 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$PersonFieldMap['firstName']!: - _$PersonPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$PersonFieldMap['lastName']!: - _$PersonPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -343,13 +346,18 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$PersonFieldMap['firstName']!: - _$PersonPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$PersonFieldMap['lastName']!: - _$PersonPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -374,13 +382,18 @@ class _$PersonDocumentReference ); final json = { if (firstName != _sentinel) - _$PersonFieldMap['firstName']!: - _$PersonPerFieldToJson.firstName(firstName as String), + _$PersonFieldMap['firstName']!: _$PersonPerFieldToJson.firstName( + firstName as String, + ), + if (firstNameFieldValue != null) _$PersonFieldMap['firstName']!: firstNameFieldValue, + if (lastName != _sentinel) - _$PersonFieldMap['lastName']!: - _$PersonPerFieldToJson.lastName(lastName as String), + _$PersonFieldMap['lastName']!: _$PersonPerFieldToJson.lastName( + lastName as String, + ), + if (lastNameFieldValue != null) _$PersonFieldMap['lastName']!: lastNameFieldValue, }; @@ -553,9 +566,9 @@ class _$PersonQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -616,7 +629,8 @@ class _$PersonQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -648,7 +662,8 @@ class _$PersonQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -692,7 +707,8 @@ class _$PersonQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.firstName(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -736,7 +752,8 @@ class _$PersonQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), whereNotIn: whereNotIn?.map((e) => _$PersonPerFieldToJson.lastName(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -757,8 +774,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -830,8 +849,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -903,8 +924,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$PersonFieldMap['firstName']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['firstName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -936,7 +959,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$PersonPerFieldToJson.firstName(startAt as String) + _$PersonPerFieldToJson.firstName(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -945,7 +968,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$PersonPerFieldToJson.firstName(startAfter as String) + _$PersonPerFieldToJson.firstName(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -954,7 +977,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$PersonPerFieldToJson.firstName(endAt as String) + _$PersonPerFieldToJson.firstName(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -963,7 +986,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$PersonPerFieldToJson.firstName(endBefore as String) + _$PersonPerFieldToJson.firstName(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -988,8 +1011,10 @@ class _$PersonQuery extends QueryReference PersonDocumentSnapshot? endBeforeDocument, PersonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$PersonFieldMap['lastName']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PersonFieldMap['lastName']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1021,7 +1046,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$PersonPerFieldToJson.lastName(startAt as String) + _$PersonPerFieldToJson.lastName(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1030,7 +1055,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$PersonPerFieldToJson.lastName(startAfter as String) + _$PersonPerFieldToJson.lastName(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1039,7 +1064,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$PersonPerFieldToJson.lastName(endAt as String) + _$PersonPerFieldToJson.lastName(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1048,7 +1073,7 @@ class _$PersonQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$PersonPerFieldToJson.lastName(endBefore as String) + _$PersonPerFieldToJson.lastName(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -1080,9 +1105,7 @@ class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { @override PersonDocumentReference get reference { - return PersonDocumentReference( - snapshot.reference, - ); + return PersonDocumentReference(snapshot.reference); } @override @@ -1091,11 +1114,7 @@ class PersonDocumentSnapshot extends FirestoreDocumentSnapshot { class PersonQuerySnapshot extends FirestoreQuerySnapshot { - PersonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + PersonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory PersonQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -1103,21 +1122,14 @@ class PersonQuerySnapshot final docs = snapshot.docs.map(PersonQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PersonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, PersonDocumentSnapshot._); }).toList(); - return PersonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return PersonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, PersonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1160,11 +1172,12 @@ class PersonQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot abstract class PublicRedirectedCollectionReference implements PublicRedirectedQuery, - FirestoreCollectionReference { - factory PublicRedirectedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$PublicRedirectedCollectionReference; + FirestoreCollectionReference< + PublicRedirected, + PublicRedirectedQuerySnapshot + > { + factory PublicRedirectedCollectionReference([FirebaseFirestore? firestore]) = + _$PublicRedirectedCollectionReference; static PublicRedirected fromFirestore( DocumentSnapshot> snapshot, @@ -1193,12 +1206,15 @@ abstract class PublicRedirectedCollectionReference class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery implements PublicRedirectedCollectionReference { - factory _$PublicRedirectedCollectionReference( - [FirebaseFirestore? firestore]) { + factory _$PublicRedirectedCollectionReference([ + FirebaseFirestore? firestore, + ]) { firestore ??= FirebaseFirestore.instance; return _$PublicRedirectedCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: PublicRedirectedCollectionReference.fromFirestore, toFirestore: PublicRedirectedCollectionReference.toFirestore, ), @@ -1221,9 +1237,7 @@ class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return PublicRedirectedDocumentReference( - reference.doc(id), - ); + return PublicRedirectedDocumentReference(reference.doc(id)); } @override @@ -1245,11 +1259,14 @@ class _$PublicRedirectedCollectionReference extends _$PublicRedirectedQuery } abstract class PublicRedirectedDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > { factory PublicRedirectedDocumentReference( - DocumentReference reference) = - _$PublicRedirectedDocumentReference; + DocumentReference reference, + ) = _$PublicRedirectedDocumentReference; DocumentReference get reference; @@ -1313,10 +1330,7 @@ abstract class PublicRedirectedDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); + Future update({String value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -1337,8 +1351,12 @@ abstract class PublicRedirectedDocumentReference }); } -class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< - PublicRedirected, PublicRedirectedDocumentSnapshot> +class _$PublicRedirectedDocumentReference + extends + FirestoreDocumentReference< + PublicRedirected, + PublicRedirectedDocumentSnapshot + > implements PublicRedirectedDocumentReference { _$PublicRedirectedDocumentReference(this.reference); @@ -1362,7 +1380,8 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(PublicRedirectedDocumentSnapshot._); } @@ -1432,8 +1451,9 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$PublicRedirected2FieldMap['value']!: - _$PublicRedirected2PerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; @@ -1452,8 +1472,9 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$PublicRedirected2FieldMap['value']!: - _$PublicRedirected2PerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; @@ -1472,8 +1493,9 @@ class _$PublicRedirectedDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$PublicRedirected2FieldMap['value']!: - _$PublicRedirected2PerFieldToJson.value(value as String), + _$PublicRedirected2FieldMap['value']!: _$PublicRedirected2PerFieldToJson + .value(value as String), + if (valueFieldValue != null) _$PublicRedirected2FieldMap['value']!: valueFieldValue, }; @@ -1623,17 +1645,17 @@ class _$PublicRedirectedQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(PublicRedirectedQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + PublicRedirectedQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -1690,7 +1712,8 @@ class _$PublicRedirectedQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1722,7 +1745,8 @@ class _$PublicRedirectedQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1756,21 +1780,26 @@ class _$PublicRedirectedQuery ? _$PublicRedirected2PerFieldToJson.value(isLessThan as String) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$PublicRedirected2PerFieldToJson - .value(isLessThanOrEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value( + isLessThanOrEqualTo as String, + ) : null, isGreaterThan: isGreaterThan != null ? _$PublicRedirected2PerFieldToJson.value(isGreaterThan as String) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$PublicRedirected2PerFieldToJson - .value(isGreaterThanOrEqualTo as String) + ? _$PublicRedirected2PerFieldToJson.value( + isGreaterThanOrEqualTo as String, + ) : null, - whereIn: - whereIn?.map((e) => _$PublicRedirected2PerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$PublicRedirected2PerFieldToJson.value(e)), - isNull: isNull ?? + whereIn: whereIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + whereNotIn: whereNotIn?.map( + (e) => _$PublicRedirected2PerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1791,8 +1820,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1864,8 +1895,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1937,8 +1970,10 @@ class _$PublicRedirectedQuery PublicRedirectedDocumentSnapshot? endBeforeDocument, PublicRedirectedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$PublicRedirected2FieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$PublicRedirected2FieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1970,7 +2005,7 @@ class _$PublicRedirectedQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$PublicRedirected2PerFieldToJson.value(startAt as String) + _$PublicRedirected2PerFieldToJson.value(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1979,7 +2014,7 @@ class _$PublicRedirectedQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$PublicRedirected2PerFieldToJson.value(startAfter as String) + _$PublicRedirected2PerFieldToJson.value(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1988,7 +2023,7 @@ class _$PublicRedirectedQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$PublicRedirected2PerFieldToJson.value(endAt as String) + _$PublicRedirected2PerFieldToJson.value(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1997,7 +2032,7 @@ class _$PublicRedirectedQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$PublicRedirected2PerFieldToJson.value(endBefore as String) + _$PublicRedirected2PerFieldToJson.value(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -2030,48 +2065,40 @@ class PublicRedirectedDocumentSnapshot @override PublicRedirectedDocumentReference get reference { - return PublicRedirectedDocumentReference( - snapshot.reference, - ); + return PublicRedirectedDocumentReference(snapshot.reference); } @override final PublicRedirected? data; } -class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< - PublicRedirected, PublicRedirectedQueryDocumentSnapshot> { - PublicRedirectedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(PublicRedirectedQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - PublicRedirectedDocumentSnapshot._, - ); + return _decodeDocumentChange(change, PublicRedirectedDocumentSnapshot._); }).toList(); - return PublicRedirectedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return PublicRedirectedQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, PublicRedirectedDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange( type: docChange.type, @@ -2088,14 +2115,14 @@ class PublicRedirectedQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class PublicRedirectedQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements PublicRedirectedDocumentSnapshot { PublicRedirectedQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -2115,11 +2142,12 @@ class PublicRedirectedQueryDocumentSnapshot abstract class SimpleFreezedCollectionReference implements SimpleFreezedQuery, - FirestoreCollectionReference { - factory SimpleFreezedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$SimpleFreezedCollectionReference; + FirestoreCollectionReference< + SimpleFreezed, + SimpleFreezedQuerySnapshot + > { + factory SimpleFreezedCollectionReference([FirebaseFirestore? firestore]) = + _$SimpleFreezedCollectionReference; static SimpleFreezed fromFirestore( DocumentSnapshot> snapshot, @@ -2152,7 +2180,9 @@ class _$SimpleFreezedCollectionReference extends _$SimpleFreezedQuery firestore ??= FirebaseFirestore.instance; return _$SimpleFreezedCollectionReference._( - firestore.collection('freezed-test').withConverter( + firestore + .collection('freezed-test') + .withConverter( fromFirestore: SimpleFreezedCollectionReference.fromFirestore, toFirestore: SimpleFreezedCollectionReference.toFirestore, ), @@ -2175,9 +2205,7 @@ class _$SimpleFreezedCollectionReference extends _$SimpleFreezedQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return SimpleFreezedDocumentReference( - reference.doc(id), - ); + return SimpleFreezedDocumentReference(reference.doc(id)); } @override @@ -2199,11 +2227,14 @@ class _$SimpleFreezedCollectionReference extends _$SimpleFreezedQuery } abstract class SimpleFreezedDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + SimpleFreezed, + SimpleFreezedDocumentSnapshot + > { factory SimpleFreezedDocumentReference( - DocumentReference reference) = - _$SimpleFreezedDocumentReference; + DocumentReference reference, + ) = _$SimpleFreezedDocumentReference; DocumentReference get reference; @@ -2267,10 +2298,7 @@ abstract class SimpleFreezedDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - int a, - FieldValue aFieldValue, - }); + Future update({int a, FieldValue aFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -2284,16 +2312,13 @@ abstract class SimpleFreezedDocumentReference /// 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, - }); + void batchUpdate(WriteBatch batch, {int a, FieldValue aFieldValue}); } -class _$SimpleFreezedDocumentReference extends FirestoreDocumentReference< - SimpleFreezed, - SimpleFreezedDocumentSnapshot> implements SimpleFreezedDocumentReference { +class _$SimpleFreezedDocumentReference + extends + FirestoreDocumentReference + implements SimpleFreezedDocumentReference { _$SimpleFreezedDocumentReference(this.reference); @override @@ -2316,7 +2341,8 @@ class _$SimpleFreezedDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(SimpleFreezedDocumentSnapshot._); } @@ -2373,18 +2399,17 @@ class _$SimpleFreezedDocumentReference extends FirestoreDocumentReference< batch.set(castedReference, json, options); } - Future update({ - Object? a = _sentinel, - FieldValue? aFieldValue, - }) async { + 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), + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, }; @@ -2402,8 +2427,10 @@ class _$SimpleFreezedDocumentReference extends FirestoreDocumentReference< ); final json = { if (a != _sentinel) - _$SimpleFreezedFieldMap['a']!: - _$SimpleFreezedPerFieldToJson.a(a as int), + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, }; @@ -2421,8 +2448,10 @@ class _$SimpleFreezedDocumentReference extends FirestoreDocumentReference< ); final json = { if (a != _sentinel) - _$SimpleFreezedFieldMap['a']!: - _$SimpleFreezedPerFieldToJson.a(a as int), + _$SimpleFreezedFieldMap['a']!: _$SimpleFreezedPerFieldToJson.a( + a as int, + ), + if (aFieldValue != null) _$SimpleFreezedFieldMap['a']!: aFieldValue, }; @@ -2571,17 +2600,17 @@ class _$SimpleFreezedQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(SimpleFreezedQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + SimpleFreezedQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -2638,7 +2667,8 @@ class _$SimpleFreezedQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2670,7 +2700,8 @@ class _$SimpleFreezedQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2714,7 +2745,8 @@ class _$SimpleFreezedQuery : null, whereIn: whereIn?.map((e) => _$SimpleFreezedPerFieldToJson.a(e)), whereNotIn: whereNotIn?.map((e) => _$SimpleFreezedPerFieldToJson.a(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -2735,8 +2767,10 @@ class _$SimpleFreezedQuery SimpleFreezedDocumentSnapshot? endBeforeDocument, SimpleFreezedDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2808,8 +2842,10 @@ class _$SimpleFreezedQuery SimpleFreezedDocumentSnapshot? endBeforeDocument, SimpleFreezedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2881,8 +2917,10 @@ class _$SimpleFreezedQuery SimpleFreezedDocumentSnapshot? endBeforeDocument, SimpleFreezedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$SimpleFreezedFieldMap['a']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$SimpleFreezedFieldMap['a']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -2914,7 +2952,7 @@ class _$SimpleFreezedQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$SimpleFreezedPerFieldToJson.a(startAt as int) + _$SimpleFreezedPerFieldToJson.a(startAt as int), ], startAtDocumentSnapshot: null, ); @@ -2923,7 +2961,7 @@ class _$SimpleFreezedQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$SimpleFreezedPerFieldToJson.a(startAfter as int) + _$SimpleFreezedPerFieldToJson.a(startAfter as int), ], startAfterDocumentSnapshot: null, ); @@ -2932,7 +2970,7 @@ class _$SimpleFreezedQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$SimpleFreezedPerFieldToJson.a(endAt as int) + _$SimpleFreezedPerFieldToJson.a(endAt as int), ], endAtDocumentSnapshot: null, ); @@ -2941,7 +2979,7 @@ class _$SimpleFreezedQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$SimpleFreezedPerFieldToJson.a(endBefore as int) + _$SimpleFreezedPerFieldToJson.a(endBefore as int), ], endBeforeDocumentSnapshot: null, ); @@ -2974,45 +3012,37 @@ class SimpleFreezedDocumentSnapshot @override SimpleFreezedDocumentReference get reference { - return SimpleFreezedDocumentReference( - snapshot.reference, - ); + return SimpleFreezedDocumentReference(snapshot.reference); } @override final SimpleFreezed? data; } -class SimpleFreezedQuerySnapshot extends FirestoreQuerySnapshot { - SimpleFreezedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(SimpleFreezedQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - SimpleFreezedDocumentSnapshot._, - ); + return _decodeDocumentChange(change, SimpleFreezedDocumentSnapshot._); }).toList(); - return SimpleFreezedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return SimpleFreezedQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, SimpleFreezedDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -3055,13 +3085,9 @@ class SimpleFreezedQueryDocumentSnapshot // ************************************************************************** SimpleFreezed _$SimpleFreezedFromJson(Map json) => - SimpleFreezed( - a: (json['a'] as num).toInt(), - ); + SimpleFreezed(a: (json['a'] as num).toInt()); -const _$SimpleFreezedFieldMap = { - 'a': 'a', -}; +const _$SimpleFreezedFieldMap = {'a': 'a'}; // ignore: unused_element abstract class _$SimpleFreezedPerFieldToJson { @@ -3070,14 +3096,12 @@ abstract class _$SimpleFreezedPerFieldToJson { } Map _$SimpleFreezedToJson(SimpleFreezed instance) => - { - 'a': instance.a, - }; + {'a': instance.a}; _Person _$PersonFromJson(Map json) => _Person( - 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 _$PersonFieldMap = { 'firstName': 'first_name', @@ -3093,18 +3117,14 @@ abstract class _$PersonPerFieldToJson { } Map _$PersonToJson(_Person instance) => { - 'first_name': instance.firstName, - 'LAST_NAME': instance.lastName, - }; + 'first_name': instance.firstName, + 'LAST_NAME': instance.lastName, +}; PublicRedirected2 _$PublicRedirected2FromJson(Map json) => - PublicRedirected2( - value: json['value'] as String, - ); + PublicRedirected2(value: json['value'] as String); -const _$PublicRedirected2FieldMap = { - 'value': 'value', -}; +const _$PublicRedirected2FieldMap = {'value': 'value'}; // ignore: unused_element abstract class _$PublicRedirected2PerFieldToJson { @@ -3113,6 +3133,4 @@ abstract class _$PublicRedirected2PerFieldToJson { } Map _$PublicRedirected2ToJson(PublicRedirected2 instance) => - { - 'value': instance.value, - }; + {'value': instance.value}; 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..3ff9923 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 @@ -35,11 +35,7 @@ class Model { final String value; } -enum TestEnum { - one, - two, - three; -} +enum TestEnum { one, two, three } @JsonSerializable() class Nested { @@ -85,8 +81,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 +131,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 +157,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 +168,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 +191,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 +209,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 +231,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.g.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.g.dart index 031de0c..f70e1fc 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 @@ -23,11 +23,12 @@ const _sentinel = _Sentinel(); abstract class IgnoredGetterCollectionReference implements IgnoredGetterQuery, - FirestoreCollectionReference { - factory IgnoredGetterCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$IgnoredGetterCollectionReference; + FirestoreCollectionReference< + IgnoredGetter, + IgnoredGetterQuerySnapshot + > { + factory IgnoredGetterCollectionReference([FirebaseFirestore? firestore]) = + _$IgnoredGetterCollectionReference; static IgnoredGetter fromFirestore( DocumentSnapshot> snapshot, @@ -60,7 +61,9 @@ class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery firestore ??= FirebaseFirestore.instance; return _$IgnoredGetterCollectionReference._( - firestore.collection('firestore-example-app/test/getter').withConverter( + firestore + .collection('firestore-example-app/test/getter') + .withConverter( fromFirestore: IgnoredGetterCollectionReference.fromFirestore, toFirestore: IgnoredGetterCollectionReference.toFirestore, ), @@ -83,9 +86,7 @@ class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return IgnoredGetterDocumentReference( - reference.doc(id), - ); + return IgnoredGetterDocumentReference(reference.doc(id)); } @override @@ -107,11 +108,14 @@ class _$IgnoredGetterCollectionReference extends _$IgnoredGetterQuery } abstract class IgnoredGetterDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + IgnoredGetter, + IgnoredGetterDocumentSnapshot + > { factory IgnoredGetterDocumentReference( - DocumentReference reference) = - _$IgnoredGetterDocumentReference; + DocumentReference reference, + ) = _$IgnoredGetterDocumentReference; DocumentReference get reference; @@ -175,10 +179,7 @@ abstract class IgnoredGetterDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); + Future update({int value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -192,16 +193,13 @@ abstract class IgnoredGetterDocumentReference /// 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, - }); + void batchUpdate(WriteBatch batch, {int value, FieldValue valueFieldValue}); } -class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< - IgnoredGetter, - IgnoredGetterDocumentSnapshot> implements IgnoredGetterDocumentReference { +class _$IgnoredGetterDocumentReference + extends + FirestoreDocumentReference + implements IgnoredGetterDocumentReference { _$IgnoredGetterDocumentReference(this.reference); @override @@ -224,7 +222,8 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(IgnoredGetterDocumentSnapshot._); } @@ -294,8 +293,10 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$IgnoredGetterFieldMap['value']!: - _$IgnoredGetterPerFieldToJson.value(value as int), + _$IgnoredGetterFieldMap['value']!: _$IgnoredGetterPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; @@ -314,8 +315,10 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$IgnoredGetterFieldMap['value']!: - _$IgnoredGetterPerFieldToJson.value(value as int), + _$IgnoredGetterFieldMap['value']!: _$IgnoredGetterPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; @@ -334,8 +337,10 @@ class _$IgnoredGetterDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$IgnoredGetterFieldMap['value']!: - _$IgnoredGetterPerFieldToJson.value(value as int), + _$IgnoredGetterFieldMap['value']!: _$IgnoredGetterPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$IgnoredGetterFieldMap['value']!: valueFieldValue, }; @@ -485,17 +490,17 @@ class _$IgnoredGetterQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(IgnoredGetterQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + IgnoredGetterQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -552,7 +557,8 @@ class _$IgnoredGetterQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -584,7 +590,8 @@ class _$IgnoredGetterQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -627,9 +634,11 @@ class _$IgnoredGetterQuery ? _$IgnoredGetterPerFieldToJson.value(isGreaterThanOrEqualTo as int) : null, whereIn: whereIn?.map((e) => _$IgnoredGetterPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$IgnoredGetterPerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$IgnoredGetterPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -650,8 +659,10 @@ class _$IgnoredGetterQuery IgnoredGetterDocumentSnapshot? endBeforeDocument, IgnoredGetterDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -723,8 +734,10 @@ class _$IgnoredGetterQuery IgnoredGetterDocumentSnapshot? endBeforeDocument, IgnoredGetterDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -796,8 +809,10 @@ class _$IgnoredGetterQuery IgnoredGetterDocumentSnapshot? endBeforeDocument, IgnoredGetterDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$IgnoredGetterFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$IgnoredGetterFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -829,7 +844,7 @@ class _$IgnoredGetterQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$IgnoredGetterPerFieldToJson.value(startAt as int) + _$IgnoredGetterPerFieldToJson.value(startAt as int), ], startAtDocumentSnapshot: null, ); @@ -838,7 +853,7 @@ class _$IgnoredGetterQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$IgnoredGetterPerFieldToJson.value(startAfter as int) + _$IgnoredGetterPerFieldToJson.value(startAfter as int), ], startAfterDocumentSnapshot: null, ); @@ -847,7 +862,7 @@ class _$IgnoredGetterQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$IgnoredGetterPerFieldToJson.value(endAt as int) + _$IgnoredGetterPerFieldToJson.value(endAt as int), ], endAtDocumentSnapshot: null, ); @@ -856,7 +871,7 @@ class _$IgnoredGetterQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$IgnoredGetterPerFieldToJson.value(endBefore as int) + _$IgnoredGetterPerFieldToJson.value(endBefore as int), ], endBeforeDocumentSnapshot: null, ); @@ -889,45 +904,37 @@ class IgnoredGetterDocumentSnapshot @override IgnoredGetterDocumentReference get reference { - return IgnoredGetterDocumentReference( - snapshot.reference, - ); + return IgnoredGetterDocumentReference(snapshot.reference); } @override final IgnoredGetter? data; } -class IgnoredGetterQuerySnapshot extends FirestoreQuerySnapshot { - IgnoredGetterQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(IgnoredGetterQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - IgnoredGetterDocumentSnapshot._, - ); + return _decodeDocumentChange(change, IgnoredGetterDocumentSnapshot._); }).toList(); - return IgnoredGetterQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return IgnoredGetterQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, IgnoredGetterDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -972,9 +979,8 @@ abstract class ModelCollectionReference implements ModelQuery, FirestoreCollectionReference { - factory ModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ModelCollectionReference; + factory ModelCollectionReference([FirebaseFirestore? firestore]) = + _$ModelCollectionReference; static Model fromFirestore( DocumentSnapshot> snapshot, @@ -983,10 +989,7 @@ abstract class ModelCollectionReference return _$ModelFromJson(snapshot.data()!); } - static Map toFirestore( - Model value, - SetOptions? options, - ) { + static Map toFirestore(Model value, SetOptions? options) { return _$ModelToJson(value); } @@ -1007,16 +1010,17 @@ class _$ModelCollectionReference extends _$ModelQuery firestore ??= FirebaseFirestore.instance; return _$ModelCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: ModelCollectionReference.fromFirestore, toFirestore: ModelCollectionReference.toFirestore, ), ); } - _$ModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$ModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -1030,9 +1034,7 @@ class _$ModelCollectionReference extends _$ModelQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ModelDocumentReference( - reference.doc(id), - ); + return ModelDocumentReference(reference.doc(id)); } @override @@ -1118,10 +1120,7 @@ abstract class ModelDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - String value, - FieldValue valueFieldValue, - }); + Future update({String value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -1234,6 +1233,7 @@ class _$ModelDocumentReference final json = { if (value != _sentinel) _$ModelFieldMap['value']!: _$ModelPerFieldToJson.value(value as String), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; @@ -1252,6 +1252,7 @@ class _$ModelDocumentReference final json = { if (value != _sentinel) _$ModelFieldMap['value']!: _$ModelPerFieldToJson.value(value as String), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; @@ -1270,6 +1271,7 @@ class _$ModelDocumentReference final json = { if (value != _sentinel) _$ModelFieldMap['value']!: _$ModelPerFieldToJson.value(value as String), + if (valueFieldValue != null) _$ModelFieldMap['value']!: valueFieldValue, }; @@ -1416,9 +1418,9 @@ class _$ModelQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -1479,7 +1481,8 @@ class _$ModelQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1511,7 +1514,8 @@ class _$ModelQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1555,7 +1559,8 @@ class _$ModelQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$ModelPerFieldToJson.value(e)), whereNotIn: whereNotIn?.map((e) => _$ModelPerFieldToJson.value(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -1576,8 +1581,10 @@ class _$ModelQuery extends QueryReference ModelDocumentSnapshot? endBeforeDocument, ModelDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1649,8 +1656,10 @@ class _$ModelQuery extends QueryReference ModelDocumentSnapshot? endBeforeDocument, ModelDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1722,8 +1731,10 @@ class _$ModelQuery extends QueryReference ModelDocumentSnapshot? endBeforeDocument, ModelDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$ModelFieldMap['value']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$ModelFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -1755,7 +1766,7 @@ class _$ModelQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$ModelPerFieldToJson.value(startAt as String) + _$ModelPerFieldToJson.value(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -1764,7 +1775,7 @@ class _$ModelQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$ModelPerFieldToJson.value(startAfter as String) + _$ModelPerFieldToJson.value(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -1773,7 +1784,7 @@ class _$ModelQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$ModelPerFieldToJson.value(endAt as String) + _$ModelPerFieldToJson.value(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -1782,7 +1793,7 @@ class _$ModelQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$ModelPerFieldToJson.value(endBefore as String) + _$ModelPerFieldToJson.value(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -1814,9 +1825,7 @@ class ModelDocumentSnapshot extends FirestoreDocumentSnapshot { @override ModelDocumentReference get reference { - return ModelDocumentReference( - snapshot.reference, - ); + return ModelDocumentReference(snapshot.reference); } @override @@ -1825,33 +1834,20 @@ class ModelDocumentSnapshot extends FirestoreDocumentSnapshot { class ModelQuerySnapshot extends FirestoreQuerySnapshot { - ModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory ModelQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + 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._, - ); + return _decodeDocumentChange(change, ModelDocumentSnapshot._); }).toList(); - return ModelQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ModelQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -1895,9 +1891,8 @@ abstract class NestedCollectionReference implements NestedQuery, FirestoreCollectionReference { - factory NestedCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$NestedCollectionReference; + factory NestedCollectionReference([FirebaseFirestore? firestore]) = + _$NestedCollectionReference; static Nested fromFirestore( DocumentSnapshot> snapshot, @@ -1906,10 +1901,7 @@ abstract class NestedCollectionReference return Nested.fromJson(snapshot.data()!); } - static Map toFirestore( - Nested value, - SetOptions? options, - ) { + static Map toFirestore(Nested value, SetOptions? options) { return value.toJson(); } @@ -1930,16 +1922,17 @@ class _$NestedCollectionReference extends _$NestedQuery firestore ??= FirebaseFirestore.instance; return _$NestedCollectionReference._( - firestore.collection('nested').withConverter( + firestore + .collection('nested') + .withConverter( fromFirestore: NestedCollectionReference.fromFirestore, toFirestore: NestedCollectionReference.toFirestore, ), ); } - _$NestedCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$NestedCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -1953,9 +1946,7 @@ class _$NestedCollectionReference extends _$NestedQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return NestedDocumentReference( - reference.doc(id), - ); + return NestedDocumentReference(reference.doc(id)); } @override @@ -2221,28 +2212,40 @@ class _$NestedDocumentReference 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, }; @@ -2275,28 +2278,40 @@ class _$NestedDocumentReference 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, }; @@ -2329,28 +2344,40 @@ class _$NestedDocumentReference 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, }; @@ -2444,67 +2471,103 @@ class _$NestedDocumentReference ); final json = { if (value != _sentinel) - _$NestedFieldMap['value']!: - _$NestedPerFieldToJson.value(value as Nested?), + _$NestedFieldMap['value']!: _$NestedPerFieldToJson.value( + value as Nested?, + ), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simple != _sentinel) - _$NestedFieldMap['simple']!: - _$NestedPerFieldToJson.simple(simple as int?), + _$NestedFieldMap['simple']!: _$NestedPerFieldToJson.simple( + simple as int?, + ), + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueList != _sentinel) - _$NestedFieldMap['valueList']!: - _$NestedPerFieldToJson.valueList(valueList as List?), + _$NestedFieldMap['valueList']!: _$NestedPerFieldToJson.valueList( + valueList as List?, + ), + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolList != _sentinel) - _$NestedFieldMap['boolList']!: - _$NestedPerFieldToJson.boolList(boolList as List?), + _$NestedFieldMap['boolList']!: _$NestedPerFieldToJson.boolList( + boolList as List?, + ), + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringList != _sentinel) - _$NestedFieldMap['stringList']!: - _$NestedPerFieldToJson.stringList(stringList as List?), + _$NestedFieldMap['stringList']!: _$NestedPerFieldToJson.stringList( + stringList as List?, + ), + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numList != _sentinel) - _$NestedFieldMap['numList']!: - _$NestedPerFieldToJson.numList(numList as List?), + _$NestedFieldMap['numList']!: _$NestedPerFieldToJson.numList( + numList as List?, + ), + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectList != _sentinel) - _$NestedFieldMap['objectList']!: - _$NestedPerFieldToJson.objectList(objectList as List?), + _$NestedFieldMap['objectList']!: _$NestedPerFieldToJson.objectList( + objectList as List?, + ), + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicList != _sentinel) - _$NestedFieldMap['dynamicList']!: - _$NestedPerFieldToJson.dynamicList(dynamicList as List?), + _$NestedFieldMap['dynamicList']!: _$NestedPerFieldToJson.dynamicList( + dynamicList as List?, + ), + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSet != _sentinel) - _$NestedFieldMap['boolSet']!: - _$NestedPerFieldToJson.boolSet(boolSet as Set?), + _$NestedFieldMap['boolSet']!: _$NestedPerFieldToJson.boolSet( + boolSet as Set?, + ), + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValue != _sentinel) - _$NestedFieldMap['enumValue']!: - _$NestedPerFieldToJson.enumValue(enumValue as TestEnum), + _$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), + _$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, }; @@ -2595,67 +2658,103 @@ class _$NestedDocumentReference ); final json = { if (value != _sentinel) - _$NestedFieldMap['value']!: - _$NestedPerFieldToJson.value(value as Nested?), + _$NestedFieldMap['value']!: _$NestedPerFieldToJson.value( + value as Nested?, + ), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simple != _sentinel) - _$NestedFieldMap['simple']!: - _$NestedPerFieldToJson.simple(simple as int?), + _$NestedFieldMap['simple']!: _$NestedPerFieldToJson.simple( + simple as int?, + ), + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueList != _sentinel) - _$NestedFieldMap['valueList']!: - _$NestedPerFieldToJson.valueList(valueList as List?), + _$NestedFieldMap['valueList']!: _$NestedPerFieldToJson.valueList( + valueList as List?, + ), + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolList != _sentinel) - _$NestedFieldMap['boolList']!: - _$NestedPerFieldToJson.boolList(boolList as List?), + _$NestedFieldMap['boolList']!: _$NestedPerFieldToJson.boolList( + boolList as List?, + ), + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringList != _sentinel) - _$NestedFieldMap['stringList']!: - _$NestedPerFieldToJson.stringList(stringList as List?), + _$NestedFieldMap['stringList']!: _$NestedPerFieldToJson.stringList( + stringList as List?, + ), + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numList != _sentinel) - _$NestedFieldMap['numList']!: - _$NestedPerFieldToJson.numList(numList as List?), + _$NestedFieldMap['numList']!: _$NestedPerFieldToJson.numList( + numList as List?, + ), + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectList != _sentinel) - _$NestedFieldMap['objectList']!: - _$NestedPerFieldToJson.objectList(objectList as List?), + _$NestedFieldMap['objectList']!: _$NestedPerFieldToJson.objectList( + objectList as List?, + ), + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicList != _sentinel) - _$NestedFieldMap['dynamicList']!: - _$NestedPerFieldToJson.dynamicList(dynamicList as List?), + _$NestedFieldMap['dynamicList']!: _$NestedPerFieldToJson.dynamicList( + dynamicList as List?, + ), + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSet != _sentinel) - _$NestedFieldMap['boolSet']!: - _$NestedPerFieldToJson.boolSet(boolSet as Set?), + _$NestedFieldMap['boolSet']!: _$NestedPerFieldToJson.boolSet( + boolSet as Set?, + ), + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValue != _sentinel) - _$NestedFieldMap['enumValue']!: - _$NestedPerFieldToJson.enumValue(enumValue as TestEnum), + _$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), + _$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, }; @@ -2746,67 +2845,103 @@ class _$NestedDocumentReference ); final json = { if (value != _sentinel) - _$NestedFieldMap['value']!: - _$NestedPerFieldToJson.value(value as Nested?), + _$NestedFieldMap['value']!: _$NestedPerFieldToJson.value( + value as Nested?, + ), + if (valueFieldValue != null) _$NestedFieldMap['value']!: valueFieldValue, + if (simple != _sentinel) - _$NestedFieldMap['simple']!: - _$NestedPerFieldToJson.simple(simple as int?), + _$NestedFieldMap['simple']!: _$NestedPerFieldToJson.simple( + simple as int?, + ), + if (simpleFieldValue != null) _$NestedFieldMap['simple']!: simpleFieldValue, + if (valueList != _sentinel) - _$NestedFieldMap['valueList']!: - _$NestedPerFieldToJson.valueList(valueList as List?), + _$NestedFieldMap['valueList']!: _$NestedPerFieldToJson.valueList( + valueList as List?, + ), + if (valueListFieldValue != null) _$NestedFieldMap['valueList']!: valueListFieldValue, + if (boolList != _sentinel) - _$NestedFieldMap['boolList']!: - _$NestedPerFieldToJson.boolList(boolList as List?), + _$NestedFieldMap['boolList']!: _$NestedPerFieldToJson.boolList( + boolList as List?, + ), + if (boolListFieldValue != null) _$NestedFieldMap['boolList']!: boolListFieldValue, + if (stringList != _sentinel) - _$NestedFieldMap['stringList']!: - _$NestedPerFieldToJson.stringList(stringList as List?), + _$NestedFieldMap['stringList']!: _$NestedPerFieldToJson.stringList( + stringList as List?, + ), + if (stringListFieldValue != null) _$NestedFieldMap['stringList']!: stringListFieldValue, + if (numList != _sentinel) - _$NestedFieldMap['numList']!: - _$NestedPerFieldToJson.numList(numList as List?), + _$NestedFieldMap['numList']!: _$NestedPerFieldToJson.numList( + numList as List?, + ), + if (numListFieldValue != null) _$NestedFieldMap['numList']!: numListFieldValue, + if (objectList != _sentinel) - _$NestedFieldMap['objectList']!: - _$NestedPerFieldToJson.objectList(objectList as List?), + _$NestedFieldMap['objectList']!: _$NestedPerFieldToJson.objectList( + objectList as List?, + ), + if (objectListFieldValue != null) _$NestedFieldMap['objectList']!: objectListFieldValue, + if (dynamicList != _sentinel) - _$NestedFieldMap['dynamicList']!: - _$NestedPerFieldToJson.dynamicList(dynamicList as List?), + _$NestedFieldMap['dynamicList']!: _$NestedPerFieldToJson.dynamicList( + dynamicList as List?, + ), + if (dynamicListFieldValue != null) _$NestedFieldMap['dynamicList']!: dynamicListFieldValue, + if (boolSet != _sentinel) - _$NestedFieldMap['boolSet']!: - _$NestedPerFieldToJson.boolSet(boolSet as Set?), + _$NestedFieldMap['boolSet']!: _$NestedPerFieldToJson.boolSet( + boolSet as Set?, + ), + if (boolSetFieldValue != null) _$NestedFieldMap['boolSet']!: boolSetFieldValue, + if (enumValue != _sentinel) - _$NestedFieldMap['enumValue']!: - _$NestedPerFieldToJson.enumValue(enumValue as TestEnum), + _$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), + _$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, }; @@ -3243,9 +3378,9 @@ class _$NestedQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -3306,7 +3441,8 @@ class _$NestedQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3338,7 +3474,8 @@ class _$NestedQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3382,7 +3519,8 @@ class _$NestedQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.value(e)), whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.value(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3426,7 +3564,8 @@ class _$NestedQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.simple(e)), whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.simple(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3460,26 +3599,29 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.valueList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .valueList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.valueList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.valueList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .valueList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.valueList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.valueList([arrayContains as Nested]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.valueList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3513,26 +3655,29 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.boolList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.boolList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.boolList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.boolList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.boolList([arrayContains as bool]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.boolList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3566,26 +3711,29 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.stringList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .stringList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.stringList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.stringList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .stringList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.stringList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.stringList([arrayContains as String]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.stringList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3625,18 +3773,20 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.numList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .numList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.numList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.numList([arrayContains as num]) as List?)! - .single + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.numList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3670,25 +3820,28 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.objectList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .objectList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.objectList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.objectList(isGreaterThan as List?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .objectList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.objectList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.objectList([arrayContains]) as List?)! - .single + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.objectList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3722,27 +3875,31 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.dynamicList(isLessThan as List?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .dynamicList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.dynamicList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .dynamicList(isGreaterThan as List?) + ? _$NestedPerFieldToJson.dynamicList( + isGreaterThan as List?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .dynamicList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.dynamicList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.dynamicList([arrayContains as dynamic]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.dynamicList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3782,19 +3939,21 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.boolSet(isGreaterThan as Set?) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .boolSet(isGreaterThanOrEqualTo as Set?) + ? _$NestedPerFieldToJson.boolSet( + isGreaterThanOrEqualTo as Set?, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.boolSet({arrayContains as bool}) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.boolSet(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3834,12 +3993,14 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.enumValue(isGreaterThan as TestEnum) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumValue(isGreaterThanOrEqualTo as TestEnum) + ? _$NestedPerFieldToJson.enumValue( + isGreaterThanOrEqualTo as TestEnum, + ) : null, whereIn: whereIn?.map((e) => _$NestedPerFieldToJson.enumValue(e)), whereNotIn: whereNotIn?.map((e) => _$NestedPerFieldToJson.enumValue(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3867,29 +4028,36 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.nullableEnumValue(isEqualTo as TestEnum?) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumValue(isNotEqualTo as TestEnum?) + ? _$NestedPerFieldToJson.nullableEnumValue( + isNotEqualTo as TestEnum?, + ) : null, isLessThan: isLessThan != null ? _$NestedPerFieldToJson.nullableEnumValue(isLessThan as TestEnum?) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumValue(isLessThanOrEqualTo as TestEnum?) + ? _$NestedPerFieldToJson.nullableEnumValue( + isLessThanOrEqualTo as TestEnum?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .nullableEnumValue(isGreaterThan as TestEnum?) + ? _$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 ?? + ? _$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), ), @@ -3923,26 +4091,29 @@ class _$NestedQuery extends QueryReference ? _$NestedPerFieldToJson.enumList(isLessThan as List) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumList(isLessThanOrEqualTo as List) + ? _$NestedPerFieldToJson.enumList( + isLessThanOrEqualTo as List, + ) : null, isGreaterThan: isGreaterThan != null ? _$NestedPerFieldToJson.enumList(isGreaterThan as List) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .enumList(isGreaterThanOrEqualTo as List) + ? _$NestedPerFieldToJson.enumList( + isGreaterThanOrEqualTo as List, + ) : null, arrayContains: arrayContains != null ? (_$NestedPerFieldToJson.enumList([arrayContains as TestEnum]) - as List?)! - .single + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.enumList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -3967,39 +4138,48 @@ class _$NestedQuery extends QueryReference $referenceWithoutCursor: $referenceWithoutCursor.where( _$NestedFieldMap['nullableEnumList']!, isEqualTo: isEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumList(isEqualTo as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isEqualTo as List?, + ) : null, isNotEqualTo: isNotEqualTo != _sentinel - ? _$NestedPerFieldToJson - .nullableEnumList(isNotEqualTo as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isNotEqualTo as List?, + ) : null, isLessThan: isLessThan != null - ? _$NestedPerFieldToJson - .nullableEnumList(isLessThan as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isLessThan as List?, + ) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumList(isLessThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isLessThanOrEqualTo as List?, + ) : null, isGreaterThan: isGreaterThan != null - ? _$NestedPerFieldToJson - .nullableEnumList(isGreaterThan as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isGreaterThan as List?, + ) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$NestedPerFieldToJson - .nullableEnumList(isGreaterThanOrEqualTo as List?) + ? _$NestedPerFieldToJson.nullableEnumList( + isGreaterThanOrEqualTo as List?, + ) : null, arrayContains: arrayContains != null - ? (_$NestedPerFieldToJson - .nullableEnumList([arrayContains as TestEnum]) as List?)! - .single + ? (_$NestedPerFieldToJson.nullableEnumList([ + arrayContains as TestEnum, + ]) + as List?)! + .single : null, arrayContainsAny: arrayContainsAny != null ? _$NestedPerFieldToJson.nullableEnumList(arrayContainsAny) - as Iterable? + as Iterable? : null, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -4020,8 +4200,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4093,8 +4275,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4166,8 +4350,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['value']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4199,7 +4385,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.value(startAt as Nested?) + _$NestedPerFieldToJson.value(startAt as Nested?), ], startAtDocumentSnapshot: null, ); @@ -4208,7 +4394,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.value(startAfter as Nested?) + _$NestedPerFieldToJson.value(startAfter as Nested?), ], startAfterDocumentSnapshot: null, ); @@ -4217,7 +4403,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.value(endAt as Nested?) + _$NestedPerFieldToJson.value(endAt as Nested?), ], endAtDocumentSnapshot: null, ); @@ -4226,7 +4412,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.value(endBefore as Nested?) + _$NestedPerFieldToJson.value(endBefore as Nested?), ], endBeforeDocumentSnapshot: null, ); @@ -4251,8 +4437,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['simple']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['simple']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4284,7 +4472,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.simple(startAt as int?) + _$NestedPerFieldToJson.simple(startAt as int?), ], startAtDocumentSnapshot: null, ); @@ -4293,7 +4481,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.simple(startAfter as int?) + _$NestedPerFieldToJson.simple(startAfter as int?), ], startAfterDocumentSnapshot: null, ); @@ -4302,7 +4490,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.simple(endAt as int?) + _$NestedPerFieldToJson.simple(endAt as int?), ], endAtDocumentSnapshot: null, ); @@ -4311,7 +4499,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.simple(endBefore as int?) + _$NestedPerFieldToJson.simple(endBefore as int?), ], endBeforeDocumentSnapshot: null, ); @@ -4336,8 +4524,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['valueList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['valueList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4369,7 +4559,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.valueList(startAt as List?) + _$NestedPerFieldToJson.valueList(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -4378,7 +4568,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.valueList(startAfter as List?) + _$NestedPerFieldToJson.valueList(startAfter as List?), ], startAfterDocumentSnapshot: null, ); @@ -4387,7 +4577,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.valueList(endAt as List?) + _$NestedPerFieldToJson.valueList(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -4396,7 +4586,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.valueList(endBefore as List?) + _$NestedPerFieldToJson.valueList(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -4421,8 +4611,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['boolList']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['boolList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4454,7 +4646,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.boolList(startAt as List?) + _$NestedPerFieldToJson.boolList(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -4463,7 +4655,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.boolList(startAfter as List?) + _$NestedPerFieldToJson.boolList(startAfter as List?), ], startAfterDocumentSnapshot: null, ); @@ -4472,7 +4664,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.boolList(endAt as List?) + _$NestedPerFieldToJson.boolList(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -4481,7 +4673,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.boolList(endBefore as List?) + _$NestedPerFieldToJson.boolList(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -4506,8 +4698,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['stringList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['stringList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4539,7 +4733,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.stringList(startAt as List?) + _$NestedPerFieldToJson.stringList(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -4548,7 +4742,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.stringList(startAfter as List?) + _$NestedPerFieldToJson.stringList(startAfter as List?), ], startAfterDocumentSnapshot: null, ); @@ -4557,7 +4751,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.stringList(endAt as List?) + _$NestedPerFieldToJson.stringList(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -4566,7 +4760,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.stringList(endBefore as List?) + _$NestedPerFieldToJson.stringList(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -4591,8 +4785,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['numList']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['numList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4624,7 +4820,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.numList(startAt as List?) + _$NestedPerFieldToJson.numList(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -4633,7 +4829,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.numList(startAfter as List?) + _$NestedPerFieldToJson.numList(startAfter as List?), ], startAfterDocumentSnapshot: null, ); @@ -4642,7 +4838,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.numList(endAt as List?) + _$NestedPerFieldToJson.numList(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -4651,7 +4847,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.numList(endBefore as List?) + _$NestedPerFieldToJson.numList(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -4676,8 +4872,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['objectList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['objectList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4709,7 +4907,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.objectList(startAt as List?) + _$NestedPerFieldToJson.objectList(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -4718,7 +4916,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.objectList(startAfter as List?) + _$NestedPerFieldToJson.objectList(startAfter as List?), ], startAfterDocumentSnapshot: null, ); @@ -4727,7 +4925,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.objectList(endAt as List?) + _$NestedPerFieldToJson.objectList(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -4736,7 +4934,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.objectList(endBefore as List?) + _$NestedPerFieldToJson.objectList(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -4761,8 +4959,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['dynamicList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['dynamicList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4794,7 +4994,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.dynamicList(startAt as List?) + _$NestedPerFieldToJson.dynamicList(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -4803,7 +5003,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.dynamicList(startAfter as List?) + _$NestedPerFieldToJson.dynamicList(startAfter as List?), ], startAfterDocumentSnapshot: null, ); @@ -4812,7 +5012,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.dynamicList(endAt as List?) + _$NestedPerFieldToJson.dynamicList(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -4821,7 +5021,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.dynamicList(endBefore as List?) + _$NestedPerFieldToJson.dynamicList(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -4846,8 +5046,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['boolSet']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['boolSet']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4879,7 +5081,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.boolSet(startAt as Set?) + _$NestedPerFieldToJson.boolSet(startAt as Set?), ], startAtDocumentSnapshot: null, ); @@ -4888,7 +5090,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.boolSet(startAfter as Set?) + _$NestedPerFieldToJson.boolSet(startAfter as Set?), ], startAfterDocumentSnapshot: null, ); @@ -4897,7 +5099,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.boolSet(endAt as Set?) + _$NestedPerFieldToJson.boolSet(endAt as Set?), ], endAtDocumentSnapshot: null, ); @@ -4906,7 +5108,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.boolSet(endBefore as Set?) + _$NestedPerFieldToJson.boolSet(endBefore as Set?), ], endBeforeDocumentSnapshot: null, ); @@ -4931,8 +5133,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['enumValue']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['enumValue']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -4964,7 +5168,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.enumValue(startAt as TestEnum) + _$NestedPerFieldToJson.enumValue(startAt as TestEnum), ], startAtDocumentSnapshot: null, ); @@ -4973,7 +5177,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.enumValue(startAfter as TestEnum) + _$NestedPerFieldToJson.enumValue(startAfter as TestEnum), ], startAfterDocumentSnapshot: null, ); @@ -4982,7 +5186,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.enumValue(endAt as TestEnum) + _$NestedPerFieldToJson.enumValue(endAt as TestEnum), ], endAtDocumentSnapshot: null, ); @@ -4991,7 +5195,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.enumValue(endBefore as TestEnum) + _$NestedPerFieldToJson.enumValue(endBefore as TestEnum), ], endBeforeDocumentSnapshot: null, ); @@ -5017,8 +5221,9 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? startAfterDocument, }) { final query = $referenceWithoutCursor.orderBy( - _$NestedFieldMap['nullableEnumValue']!, - descending: descending); + _$NestedFieldMap['nullableEnumValue']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -5050,7 +5255,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.nullableEnumValue(startAt as TestEnum?) + _$NestedPerFieldToJson.nullableEnumValue(startAt as TestEnum?), ], startAtDocumentSnapshot: null, ); @@ -5059,7 +5264,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.nullableEnumValue(startAfter as TestEnum?) + _$NestedPerFieldToJson.nullableEnumValue(startAfter as TestEnum?), ], startAfterDocumentSnapshot: null, ); @@ -5068,7 +5273,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.nullableEnumValue(endAt as TestEnum?) + _$NestedPerFieldToJson.nullableEnumValue(endAt as TestEnum?), ], endAtDocumentSnapshot: null, ); @@ -5077,7 +5282,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.nullableEnumValue(endBefore as TestEnum?) + _$NestedPerFieldToJson.nullableEnumValue(endBefore as TestEnum?), ], endBeforeDocumentSnapshot: null, ); @@ -5102,8 +5307,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$NestedFieldMap['enumList']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['enumList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -5135,7 +5342,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.enumList(startAt as List) + _$NestedPerFieldToJson.enumList(startAt as List), ], startAtDocumentSnapshot: null, ); @@ -5144,7 +5351,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.enumList(startAfter as List) + _$NestedPerFieldToJson.enumList(startAfter as List), ], startAfterDocumentSnapshot: null, ); @@ -5153,7 +5360,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.enumList(endAt as List) + _$NestedPerFieldToJson.enumList(endAt as List), ], endAtDocumentSnapshot: null, ); @@ -5162,7 +5369,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.enumList(endBefore as List) + _$NestedPerFieldToJson.enumList(endBefore as List), ], endBeforeDocumentSnapshot: null, ); @@ -5187,8 +5394,10 @@ class _$NestedQuery extends QueryReference NestedDocumentSnapshot? endBeforeDocument, NestedDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$NestedFieldMap['nullableEnumList']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$NestedFieldMap['nullableEnumList']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -5220,7 +5429,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$NestedPerFieldToJson.nullableEnumList(startAt as List?) + _$NestedPerFieldToJson.nullableEnumList(startAt as List?), ], startAtDocumentSnapshot: null, ); @@ -5229,7 +5438,9 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$NestedPerFieldToJson.nullableEnumList(startAfter as List?) + _$NestedPerFieldToJson.nullableEnumList( + startAfter as List?, + ), ], startAfterDocumentSnapshot: null, ); @@ -5238,7 +5449,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$NestedPerFieldToJson.nullableEnumList(endAt as List?) + _$NestedPerFieldToJson.nullableEnumList(endAt as List?), ], endAtDocumentSnapshot: null, ); @@ -5247,7 +5458,7 @@ class _$NestedQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$NestedPerFieldToJson.nullableEnumList(endBefore as List?) + _$NestedPerFieldToJson.nullableEnumList(endBefore as List?), ], endBeforeDocumentSnapshot: null, ); @@ -5279,9 +5490,7 @@ class NestedDocumentSnapshot extends FirestoreDocumentSnapshot { @override NestedDocumentReference get reference { - return NestedDocumentReference( - snapshot.reference, - ); + return NestedDocumentReference(snapshot.reference); } @override @@ -5290,11 +5499,7 @@ class NestedDocumentSnapshot extends FirestoreDocumentSnapshot { class NestedQuerySnapshot extends FirestoreQuerySnapshot { - NestedQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + NestedQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory NestedQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -5302,21 +5507,14 @@ class NestedQuerySnapshot final docs = snapshot.docs.map(NestedQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - NestedDocumentSnapshot._, - ); + return _decodeDocumentChange(change, NestedDocumentSnapshot._); }).toList(); - return NestedQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return NestedQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, NestedDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -5360,9 +5558,8 @@ abstract class EmptyModelCollectionReference implements EmptyModelQuery, FirestoreCollectionReference { - factory EmptyModelCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$EmptyModelCollectionReference; + factory EmptyModelCollectionReference([FirebaseFirestore? firestore]) = + _$EmptyModelCollectionReference; static EmptyModel fromFirestore( DocumentSnapshot> snapshot, @@ -5395,16 +5592,17 @@ class _$EmptyModelCollectionReference extends _$EmptyModelQuery firestore ??= FirebaseFirestore.instance; return _$EmptyModelCollectionReference._( - firestore.collection('config').withConverter( + firestore + .collection('config') + .withConverter( fromFirestore: EmptyModelCollectionReference.fromFirestore, toFirestore: EmptyModelCollectionReference.toFirestore, ), ); } - _$EmptyModelCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$EmptyModelCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -5418,9 +5616,7 @@ class _$EmptyModelCollectionReference extends _$EmptyModelQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return EmptyModelDocumentReference( - reference.doc(id), - ); + return EmptyModelDocumentReference(reference.doc(id)); } @override @@ -5607,17 +5803,17 @@ class _$EmptyModelQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(EmptyModelQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + EmptyModelQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -5674,7 +5870,8 @@ class _$EmptyModelQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -5706,7 +5903,8 @@ class _$EmptyModelQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -5727,8 +5925,10 @@ class _$EmptyModelQuery EmptyModelDocumentSnapshot? endBeforeDocument, EmptyModelDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -5800,8 +6000,10 @@ class _$EmptyModelQuery EmptyModelDocumentSnapshot? endBeforeDocument, EmptyModelDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -5880,22 +6082,17 @@ class EmptyModelDocumentSnapshot extends FirestoreDocumentSnapshot { @override EmptyModelDocumentReference get reference { - return EmptyModelDocumentReference( - snapshot.reference, - ); + return EmptyModelDocumentReference(snapshot.reference); } @override final EmptyModel? data; } -class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot { - EmptyModelQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class EmptyModelQuerySnapshot + extends + FirestoreQuerySnapshot { + EmptyModelQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory EmptyModelQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -5903,21 +6100,14 @@ class EmptyModelQuerySnapshot extends FirestoreQuerySnapshot - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, EmptyModelDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -5962,9 +6152,8 @@ abstract class OptionalJsonCollectionReference implements OptionalJsonQuery, FirestoreCollectionReference { - factory OptionalJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$OptionalJsonCollectionReference; + factory OptionalJsonCollectionReference([FirebaseFirestore? firestore]) = + _$OptionalJsonCollectionReference; static OptionalJson fromFirestore( DocumentSnapshot> snapshot, @@ -5997,7 +6186,9 @@ class _$OptionalJsonCollectionReference extends _$OptionalJsonQuery firestore ??= FirebaseFirestore.instance; return _$OptionalJsonCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: OptionalJsonCollectionReference.fromFirestore, toFirestore: OptionalJsonCollectionReference.toFirestore, ), @@ -6020,9 +6211,7 @@ class _$OptionalJsonCollectionReference extends _$OptionalJsonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return OptionalJsonDocumentReference( - reference.doc(id), - ); + return OptionalJsonDocumentReference(reference.doc(id)); } @override @@ -6043,11 +6232,12 @@ class _$OptionalJsonCollectionReference extends _$OptionalJsonQuery int get hashCode => Object.hash(runtimeType, reference); } -abstract class OptionalJsonDocumentReference extends FirestoreDocumentReference< - OptionalJson, OptionalJsonDocumentSnapshot> { +abstract class OptionalJsonDocumentReference + extends + FirestoreDocumentReference { factory OptionalJsonDocumentReference( - DocumentReference reference) = - _$OptionalJsonDocumentReference; + DocumentReference reference, + ) = _$OptionalJsonDocumentReference; DocumentReference get reference; @@ -6111,10 +6301,7 @@ abstract class OptionalJsonDocumentReference extends FirestoreDocumentReference< /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); + Future update({int value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -6128,16 +6315,13 @@ abstract class OptionalJsonDocumentReference extends FirestoreDocumentReference< /// 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, - }); + void batchUpdate(WriteBatch batch, {int value, FieldValue valueFieldValue}); } -class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< - OptionalJson, - OptionalJsonDocumentSnapshot> implements OptionalJsonDocumentReference { +class _$OptionalJsonDocumentReference + extends + FirestoreDocumentReference + implements OptionalJsonDocumentReference { _$OptionalJsonDocumentReference(this.reference); @override @@ -6229,8 +6413,10 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$OptionalJsonFieldMap['value']!: - _$OptionalJsonPerFieldToJson.value(value as int), + _$OptionalJsonFieldMap['value']!: _$OptionalJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$OptionalJsonFieldMap['value']!: valueFieldValue, }; @@ -6249,8 +6435,10 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$OptionalJsonFieldMap['value']!: - _$OptionalJsonPerFieldToJson.value(value as int), + _$OptionalJsonFieldMap['value']!: _$OptionalJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$OptionalJsonFieldMap['value']!: valueFieldValue, }; @@ -6269,8 +6457,10 @@ class _$OptionalJsonDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$OptionalJsonFieldMap['value']!: - _$OptionalJsonPerFieldToJson.value(value as int), + _$OptionalJsonFieldMap['value']!: _$OptionalJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$OptionalJsonFieldMap['value']!: valueFieldValue, }; @@ -6420,17 +6610,17 @@ class _$OptionalJsonQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(OptionalJsonQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + OptionalJsonQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -6487,7 +6677,8 @@ class _$OptionalJsonQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -6519,7 +6710,8 @@ class _$OptionalJsonQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -6562,9 +6754,11 @@ class _$OptionalJsonQuery ? _$OptionalJsonPerFieldToJson.value(isGreaterThanOrEqualTo as int) : null, whereIn: whereIn?.map((e) => _$OptionalJsonPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$OptionalJsonPerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$OptionalJsonPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -6585,8 +6779,10 @@ class _$OptionalJsonQuery OptionalJsonDocumentSnapshot? endBeforeDocument, OptionalJsonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -6658,8 +6854,10 @@ class _$OptionalJsonQuery OptionalJsonDocumentSnapshot? endBeforeDocument, OptionalJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -6731,8 +6929,10 @@ class _$OptionalJsonQuery OptionalJsonDocumentSnapshot? endBeforeDocument, OptionalJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$OptionalJsonFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$OptionalJsonFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -6764,7 +6964,7 @@ class _$OptionalJsonQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$OptionalJsonPerFieldToJson.value(startAt as int) + _$OptionalJsonPerFieldToJson.value(startAt as int), ], startAtDocumentSnapshot: null, ); @@ -6773,7 +6973,7 @@ class _$OptionalJsonQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$OptionalJsonPerFieldToJson.value(startAfter as int) + _$OptionalJsonPerFieldToJson.value(startAfter as int), ], startAfterDocumentSnapshot: null, ); @@ -6782,7 +6982,7 @@ class _$OptionalJsonQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$OptionalJsonPerFieldToJson.value(endAt as int) + _$OptionalJsonPerFieldToJson.value(endAt as int), ], endAtDocumentSnapshot: null, ); @@ -6791,7 +6991,7 @@ class _$OptionalJsonQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$OptionalJsonPerFieldToJson.value(endBefore as int) + _$OptionalJsonPerFieldToJson.value(endBefore as int), ], endBeforeDocumentSnapshot: null, ); @@ -6824,45 +7024,37 @@ class OptionalJsonDocumentSnapshot @override OptionalJsonDocumentReference get reference { - return OptionalJsonDocumentReference( - snapshot.reference, - ); + return OptionalJsonDocumentReference(snapshot.reference); } @override final OptionalJson? data; } -class OptionalJsonQuerySnapshot extends FirestoreQuerySnapshot { - OptionalJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(OptionalJsonQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - OptionalJsonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, OptionalJsonDocumentSnapshot._); }).toList(); - return OptionalJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return OptionalJsonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, OptionalJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -6907,9 +7099,8 @@ abstract class MixedJsonCollectionReference implements MixedJsonQuery, FirestoreCollectionReference { - factory MixedJsonCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$MixedJsonCollectionReference; + factory MixedJsonCollectionReference([FirebaseFirestore? firestore]) = + _$MixedJsonCollectionReference; static MixedJson fromFirestore( DocumentSnapshot> snapshot, @@ -6942,16 +7133,17 @@ class _$MixedJsonCollectionReference extends _$MixedJsonQuery firestore ??= FirebaseFirestore.instance; return _$MixedJsonCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: MixedJsonCollectionReference.fromFirestore, toFirestore: MixedJsonCollectionReference.toFirestore, ), ); } - _$MixedJsonCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$MixedJsonCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -6965,9 +7157,7 @@ class _$MixedJsonCollectionReference extends _$MixedJsonQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return MixedJsonDocumentReference( - reference.doc(id), - ); + return MixedJsonDocumentReference(reference.doc(id)); } @override @@ -7053,10 +7243,7 @@ abstract class MixedJsonDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - int value, - FieldValue valueFieldValue, - }); + Future update({int value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -7070,11 +7257,7 @@ abstract class MixedJsonDocumentReference /// 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, - }); + void batchUpdate(WriteBatch batch, {int value, FieldValue valueFieldValue}); } class _$MixedJsonDocumentReference @@ -7171,8 +7354,10 @@ class _$MixedJsonDocumentReference ); final json = { if (value != _sentinel) - _$MixedJsonFieldMap['value']!: - _$MixedJsonPerFieldToJson.value(value as int), + _$MixedJsonFieldMap['value']!: _$MixedJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$MixedJsonFieldMap['value']!: valueFieldValue, }; @@ -7191,8 +7376,10 @@ class _$MixedJsonDocumentReference ); final json = { if (value != _sentinel) - _$MixedJsonFieldMap['value']!: - _$MixedJsonPerFieldToJson.value(value as int), + _$MixedJsonFieldMap['value']!: _$MixedJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$MixedJsonFieldMap['value']!: valueFieldValue, }; @@ -7211,8 +7398,10 @@ class _$MixedJsonDocumentReference ); final json = { if (value != _sentinel) - _$MixedJsonFieldMap['value']!: - _$MixedJsonPerFieldToJson.value(value as int), + _$MixedJsonFieldMap['value']!: _$MixedJsonPerFieldToJson.value( + value as int, + ), + if (valueFieldValue != null) _$MixedJsonFieldMap['value']!: valueFieldValue, }; @@ -7361,9 +7550,9 @@ class _$MixedJsonQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -7426,7 +7615,8 @@ class _$MixedJsonQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -7458,7 +7648,8 @@ class _$MixedJsonQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -7502,7 +7693,8 @@ class _$MixedJsonQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$MixedJsonPerFieldToJson.value(e)), whereNotIn: whereNotIn?.map((e) => _$MixedJsonPerFieldToJson.value(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -7523,8 +7715,10 @@ class _$MixedJsonQuery extends QueryReference MixedJsonDocumentSnapshot? endBeforeDocument, MixedJsonDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -7596,8 +7790,10 @@ class _$MixedJsonQuery extends QueryReference MixedJsonDocumentSnapshot? endBeforeDocument, MixedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -7669,8 +7865,10 @@ class _$MixedJsonQuery extends QueryReference MixedJsonDocumentSnapshot? endBeforeDocument, MixedJsonDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$MixedJsonFieldMap['value']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$MixedJsonFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -7702,7 +7900,7 @@ class _$MixedJsonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$MixedJsonPerFieldToJson.value(startAt as int) + _$MixedJsonPerFieldToJson.value(startAt as int), ], startAtDocumentSnapshot: null, ); @@ -7711,7 +7909,7 @@ class _$MixedJsonQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$MixedJsonPerFieldToJson.value(startAfter as int) + _$MixedJsonPerFieldToJson.value(startAfter as int), ], startAfterDocumentSnapshot: null, ); @@ -7720,7 +7918,7 @@ class _$MixedJsonQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$MixedJsonPerFieldToJson.value(endAt as int) + _$MixedJsonPerFieldToJson.value(endAt as int), ], endAtDocumentSnapshot: null, ); @@ -7729,7 +7927,7 @@ class _$MixedJsonQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$MixedJsonPerFieldToJson.value(endBefore as int) + _$MixedJsonPerFieldToJson.value(endBefore as int), ], endBeforeDocumentSnapshot: null, ); @@ -7761,9 +7959,7 @@ class MixedJsonDocumentSnapshot extends FirestoreDocumentSnapshot { @override MixedJsonDocumentReference get reference { - return MixedJsonDocumentReference( - snapshot.reference, - ); + return MixedJsonDocumentReference(snapshot.reference); } @override @@ -7772,11 +7968,7 @@ class MixedJsonDocumentSnapshot extends FirestoreDocumentSnapshot { class MixedJsonQuerySnapshot extends FirestoreQuerySnapshot { - MixedJsonQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + MixedJsonQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory MixedJsonQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -7784,21 +7976,14 @@ class MixedJsonQuerySnapshot final docs = snapshot.docs.map(MixedJsonQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - MixedJsonDocumentSnapshot._, - ); + return _decodeDocumentChange(change, MixedJsonDocumentSnapshot._); }).toList(); - return MixedJsonQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return MixedJsonQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, MixedJsonDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -7843,9 +8028,8 @@ abstract class RootCollectionReference implements RootQuery, FirestoreCollectionReference { - factory RootCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$RootCollectionReference; + factory RootCollectionReference([FirebaseFirestore? firestore]) = + _$RootCollectionReference; static Root fromFirestore( DocumentSnapshot> snapshot, @@ -7854,10 +8038,7 @@ abstract class RootCollectionReference return Root.fromJson(snapshot.data()!); } - static Map toFirestore( - Root value, - SetOptions? options, - ) { + static Map toFirestore(Root value, SetOptions? options) { return value.toJson(); } @@ -7878,16 +8059,17 @@ class _$RootCollectionReference extends _$RootQuery firestore ??= FirebaseFirestore.instance; return _$RootCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: RootCollectionReference.fromFirestore, toFirestore: RootCollectionReference.toFirestore, ), ); } - _$RootCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$RootCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -7901,9 +8083,7 @@ class _$RootCollectionReference extends _$RootQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return RootDocumentReference( - reference.doc(id), - ); + return RootDocumentReference(reference.doc(id)); } @override @@ -7934,24 +8114,16 @@ abstract class RootDocumentReference return _$RootCollectionReference(reference.firestore); } - late final SubCollectionReference sub = _$SubCollectionReference( - reference, - ); + late final SubCollectionReference sub = _$SubCollectionReference(reference); late final AsCamelCaseCollectionReference asCamelCase = - _$AsCamelCaseCollectionReference( - reference, - ); + _$AsCamelCaseCollectionReference(reference); late final CustomSubNameCollectionReference thisIsACustomName = - _$CustomSubNameCollectionReference( - reference, - ); + _$CustomSubNameCollectionReference(reference); late final ThisIsACustomPrefixCollectionReference customClassPrefix = - _$ThisIsACustomPrefixCollectionReference( - reference, - ); + _$ThisIsACustomPrefixCollectionReference(reference); @override Stream snapshots(); @@ -8054,24 +8226,16 @@ class _$RootDocumentReference return _$RootCollectionReference(reference.firestore); } - late final SubCollectionReference sub = _$SubCollectionReference( - reference, - ); + late final SubCollectionReference sub = _$SubCollectionReference(reference); late final AsCamelCaseCollectionReference asCamelCase = - _$AsCamelCaseCollectionReference( - reference, - ); + _$AsCamelCaseCollectionReference(reference); late final CustomSubNameCollectionReference thisIsACustomName = - _$CustomSubNameCollectionReference( - reference, - ); + _$CustomSubNameCollectionReference(reference); late final ThisIsACustomPrefixCollectionReference customClassPrefix = - _$ThisIsACustomPrefixCollectionReference( - reference, - ); + _$ThisIsACustomPrefixCollectionReference(reference); @override Stream snapshots() { @@ -8098,6 +8262,7 @@ class _$RootDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -8120,6 +8285,7 @@ class _$RootDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -8142,6 +8308,7 @@ class _$RootDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -8169,13 +8336,18 @@ class _$RootDocumentReference ); final json = { if (nonNullable != _sentinel) - _$RootFieldMap['nonNullable']!: - _$RootPerFieldToJson.nonNullable(nonNullable as String), + _$RootFieldMap['nonNullable']!: _$RootPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$RootFieldMap['nullable']!: - _$RootPerFieldToJson.nullable(nullable as int?), + _$RootFieldMap['nullable']!: _$RootPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -8200,13 +8372,18 @@ class _$RootDocumentReference ); final json = { if (nonNullable != _sentinel) - _$RootFieldMap['nonNullable']!: - _$RootPerFieldToJson.nonNullable(nonNullable as String), + _$RootFieldMap['nonNullable']!: _$RootPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$RootFieldMap['nullable']!: - _$RootPerFieldToJson.nullable(nullable as int?), + _$RootFieldMap['nullable']!: _$RootPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -8231,13 +8408,18 @@ class _$RootDocumentReference ); final json = { if (nonNullable != _sentinel) - _$RootFieldMap['nonNullable']!: - _$RootPerFieldToJson.nonNullable(nonNullable as String), + _$RootFieldMap['nonNullable']!: _$RootPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$RootFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$RootFieldMap['nullable']!: - _$RootPerFieldToJson.nullable(nullable as int?), + _$RootFieldMap['nullable']!: _$RootPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$RootFieldMap['nullable']!: nullableFieldValue, }; @@ -8409,9 +8591,9 @@ class _$RootQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -8472,7 +8654,8 @@ class _$RootQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -8504,7 +8687,8 @@ class _$RootQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -8548,7 +8732,8 @@ class _$RootQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$RootPerFieldToJson.nonNullable(e)), whereNotIn: whereNotIn?.map((e) => _$RootPerFieldToJson.nonNullable(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -8592,7 +8777,8 @@ class _$RootQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$RootPerFieldToJson.nullable(e)), whereNotIn: whereNotIn?.map((e) => _$RootPerFieldToJson.nullable(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -8613,8 +8799,10 @@ class _$RootQuery extends QueryReference RootDocumentSnapshot? endBeforeDocument, RootDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -8686,8 +8874,10 @@ class _$RootQuery extends QueryReference RootDocumentSnapshot? endBeforeDocument, RootDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -8759,8 +8949,10 @@ class _$RootQuery extends QueryReference RootDocumentSnapshot? endBeforeDocument, RootDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$RootFieldMap['nonNullable']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$RootFieldMap['nonNullable']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -8792,7 +8984,7 @@ class _$RootQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$RootPerFieldToJson.nonNullable(startAt as String) + _$RootPerFieldToJson.nonNullable(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -8801,7 +8993,7 @@ class _$RootQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$RootPerFieldToJson.nonNullable(startAfter as String) + _$RootPerFieldToJson.nonNullable(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -8810,7 +9002,7 @@ class _$RootQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$RootPerFieldToJson.nonNullable(endAt as String) + _$RootPerFieldToJson.nonNullable(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -8819,7 +9011,7 @@ class _$RootQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$RootPerFieldToJson.nonNullable(endBefore as String) + _$RootPerFieldToJson.nonNullable(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -8844,8 +9036,10 @@ class _$RootQuery extends QueryReference RootDocumentSnapshot? endBeforeDocument, RootDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$RootFieldMap['nullable']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$RootFieldMap['nullable']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -8877,7 +9071,7 @@ class _$RootQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$RootPerFieldToJson.nullable(startAt as int?) + _$RootPerFieldToJson.nullable(startAt as int?), ], startAtDocumentSnapshot: null, ); @@ -8886,7 +9080,7 @@ class _$RootQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$RootPerFieldToJson.nullable(startAfter as int?) + _$RootPerFieldToJson.nullable(startAfter as int?), ], startAfterDocumentSnapshot: null, ); @@ -8895,7 +9089,7 @@ class _$RootQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$RootPerFieldToJson.nullable(endAt as int?) + _$RootPerFieldToJson.nullable(endAt as int?), ], endAtDocumentSnapshot: null, ); @@ -8904,7 +9098,7 @@ class _$RootQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$RootPerFieldToJson.nullable(endBefore as int?) + _$RootPerFieldToJson.nullable(endBefore as int?), ], endBeforeDocumentSnapshot: null, ); @@ -8936,9 +9130,7 @@ class RootDocumentSnapshot extends FirestoreDocumentSnapshot { @override RootDocumentReference get reference { - return RootDocumentReference( - snapshot.reference, - ); + return RootDocumentReference(snapshot.reference); } @override @@ -8947,29 +9139,16 @@ class RootDocumentSnapshot extends FirestoreDocumentSnapshot { class RootQuerySnapshot extends FirestoreQuerySnapshot { - RootQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory RootQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + 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._, - ); + return _decodeDocumentChange(change, RootDocumentSnapshot._); }).toList(); - return RootQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return RootQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange _decodeDocumentChange( @@ -9014,9 +9193,8 @@ class RootQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot /// (using the methods inherited from Query). abstract class SubCollectionReference implements SubQuery, FirestoreCollectionReference { - factory SubCollectionReference( - DocumentReference parent, - ) = _$SubCollectionReference; + factory SubCollectionReference(DocumentReference parent) = + _$SubCollectionReference; static Sub fromFirestore( DocumentSnapshot> snapshot, @@ -9025,10 +9203,7 @@ abstract class SubCollectionReference return Sub.fromJson(snapshot.data()!); } - static Map toFirestore( - Sub value, - SetOptions? options, - ) { + static Map toFirestore(Sub value, SetOptions? options) { return value.toJson(); } @@ -9048,22 +9223,20 @@ abstract class SubCollectionReference class _$SubCollectionReference extends _$SubQuery implements SubCollectionReference { - factory _$SubCollectionReference( - DocumentReference parent, - ) { + factory _$SubCollectionReference(DocumentReference parent) { return _$SubCollectionReference._( RootDocumentReference(parent), - parent.collection('sub').withConverter( + parent + .collection('sub') + .withConverter( fromFirestore: SubCollectionReference.fromFirestore, toFirestore: SubCollectionReference.toFirestore, ), ); } - _$SubCollectionReference._( - this.parent, - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$SubCollectionReference._(this.parent, CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); @override final RootDocumentReference parent; @@ -9080,9 +9253,7 @@ class _$SubCollectionReference extends _$SubQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return SubDocumentReference( - reference.doc(id), - ); + return SubDocumentReference(reference.doc(id)); } @override @@ -9249,6 +9420,7 @@ class _$SubDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9271,6 +9443,7 @@ class _$SubDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9293,6 +9466,7 @@ class _$SubDocumentReference ...model.toJson(), if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9320,13 +9494,18 @@ class _$SubDocumentReference ); final json = { if (nonNullable != _sentinel) - _$SubFieldMap['nonNullable']!: - _$SubPerFieldToJson.nonNullable(nonNullable as String), + _$SubFieldMap['nonNullable']!: _$SubPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$SubFieldMap['nullable']!: - _$SubPerFieldToJson.nullable(nullable as int?), + _$SubFieldMap['nullable']!: _$SubPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9351,13 +9530,18 @@ class _$SubDocumentReference ); final json = { if (nonNullable != _sentinel) - _$SubFieldMap['nonNullable']!: - _$SubPerFieldToJson.nonNullable(nonNullable as String), + _$SubFieldMap['nonNullable']!: _$SubPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$SubFieldMap['nullable']!: - _$SubPerFieldToJson.nullable(nullable as int?), + _$SubFieldMap['nullable']!: _$SubPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9382,13 +9566,18 @@ class _$SubDocumentReference ); final json = { if (nonNullable != _sentinel) - _$SubFieldMap['nonNullable']!: - _$SubPerFieldToJson.nonNullable(nonNullable as String), + _$SubFieldMap['nonNullable']!: _$SubPerFieldToJson.nonNullable( + nonNullable as String, + ), + if (nonNullableFieldValue != null) _$SubFieldMap['nonNullable']!: nonNullableFieldValue, + if (nullable != _sentinel) - _$SubFieldMap['nullable']!: - _$SubPerFieldToJson.nullable(nullable as int?), + _$SubFieldMap['nullable']!: _$SubPerFieldToJson.nullable( + nullable as int?, + ), + if (nullableFieldValue != null) _$SubFieldMap['nullable']!: nullableFieldValue, }; @@ -9560,9 +9749,9 @@ class _$SubQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -9623,7 +9812,8 @@ class _$SubQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -9655,7 +9845,8 @@ class _$SubQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -9699,7 +9890,8 @@ class _$SubQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$SubPerFieldToJson.nonNullable(e)), whereNotIn: whereNotIn?.map((e) => _$SubPerFieldToJson.nonNullable(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -9743,7 +9935,8 @@ class _$SubQuery extends QueryReference : null, whereIn: whereIn?.map((e) => _$SubPerFieldToJson.nullable(e)), whereNotIn: whereNotIn?.map((e) => _$SubPerFieldToJson.nullable(e)), - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -9764,8 +9957,10 @@ class _$SubQuery extends QueryReference SubDocumentSnapshot? endBeforeDocument, SubDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -9837,8 +10032,10 @@ class _$SubQuery extends QueryReference SubDocumentSnapshot? endBeforeDocument, SubDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -9910,8 +10107,10 @@ class _$SubQuery extends QueryReference SubDocumentSnapshot? endBeforeDocument, SubDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$SubFieldMap['nonNullable']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$SubFieldMap['nonNullable']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -9943,7 +10142,7 @@ class _$SubQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$SubPerFieldToJson.nonNullable(startAt as String) + _$SubPerFieldToJson.nonNullable(startAt as String), ], startAtDocumentSnapshot: null, ); @@ -9952,7 +10151,7 @@ class _$SubQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$SubPerFieldToJson.nonNullable(startAfter as String) + _$SubPerFieldToJson.nonNullable(startAfter as String), ], startAfterDocumentSnapshot: null, ); @@ -9961,7 +10160,7 @@ class _$SubQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$SubPerFieldToJson.nonNullable(endAt as String) + _$SubPerFieldToJson.nonNullable(endAt as String), ], endAtDocumentSnapshot: null, ); @@ -9970,7 +10169,7 @@ class _$SubQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$SubPerFieldToJson.nonNullable(endBefore as String) + _$SubPerFieldToJson.nonNullable(endBefore as String), ], endBeforeDocumentSnapshot: null, ); @@ -9995,8 +10194,10 @@ class _$SubQuery extends QueryReference SubDocumentSnapshot? endBeforeDocument, SubDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(_$SubFieldMap['nullable']!, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$SubFieldMap['nullable']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -10028,7 +10229,7 @@ class _$SubQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$SubPerFieldToJson.nullable(startAt as int?) + _$SubPerFieldToJson.nullable(startAt as int?), ], startAtDocumentSnapshot: null, ); @@ -10037,7 +10238,7 @@ class _$SubQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$SubPerFieldToJson.nullable(startAfter as int?) + _$SubPerFieldToJson.nullable(startAfter as int?), ], startAfterDocumentSnapshot: null, ); @@ -10046,7 +10247,7 @@ class _$SubQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$SubPerFieldToJson.nullable(endAt as int?) + _$SubPerFieldToJson.nullable(endAt as int?), ], endAtDocumentSnapshot: null, ); @@ -10055,7 +10256,7 @@ class _$SubQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$SubPerFieldToJson.nullable(endBefore as int?) + _$SubPerFieldToJson.nullable(endBefore as int?), ], endBeforeDocumentSnapshot: null, ); @@ -10087,9 +10288,7 @@ class SubDocumentSnapshot extends FirestoreDocumentSnapshot { @override SubDocumentReference get reference { - return SubDocumentReference( - snapshot.reference, - ); + return SubDocumentReference(snapshot.reference); } @override @@ -10098,29 +10297,16 @@ class SubDocumentSnapshot extends FirestoreDocumentSnapshot { class SubQuerySnapshot extends FirestoreQuerySnapshot { - SubQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory SubQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { + 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._, - ); + return _decodeDocumentChange(change, SubDocumentSnapshot._); }).toList(); - return SubQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return SubQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange _decodeDocumentChange( @@ -10167,9 +10353,8 @@ abstract class AsCamelCaseCollectionReference implements AsCamelCaseQuery, FirestoreCollectionReference { - factory AsCamelCaseCollectionReference( - DocumentReference parent, - ) = _$AsCamelCaseCollectionReference; + factory AsCamelCaseCollectionReference(DocumentReference parent) = + _$AsCamelCaseCollectionReference; static AsCamelCase fromFirestore( DocumentSnapshot> snapshot, @@ -10201,12 +10386,12 @@ abstract class AsCamelCaseCollectionReference class _$AsCamelCaseCollectionReference extends _$AsCamelCaseQuery implements AsCamelCaseCollectionReference { - factory _$AsCamelCaseCollectionReference( - DocumentReference parent, - ) { + factory _$AsCamelCaseCollectionReference(DocumentReference parent) { return _$AsCamelCaseCollectionReference._( RootDocumentReference(parent), - parent.collection('as-camel-case').withConverter( + parent + .collection('as-camel-case') + .withConverter( fromFirestore: AsCamelCaseCollectionReference.fromFirestore, toFirestore: AsCamelCaseCollectionReference.toFirestore, ), @@ -10233,9 +10418,7 @@ class _$AsCamelCaseCollectionReference extends _$AsCamelCaseQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return AsCamelCaseDocumentReference( - reference.doc(id), - ); + return AsCamelCaseDocumentReference(reference.doc(id)); } @override @@ -10256,11 +10439,12 @@ class _$AsCamelCaseCollectionReference extends _$AsCamelCaseQuery int get hashCode => Object.hash(runtimeType, reference); } -abstract class AsCamelCaseDocumentReference extends FirestoreDocumentReference< - AsCamelCase, AsCamelCaseDocumentSnapshot> { +abstract class AsCamelCaseDocumentReference + extends + FirestoreDocumentReference { factory AsCamelCaseDocumentReference( - DocumentReference reference) = - _$AsCamelCaseDocumentReference; + DocumentReference reference, + ) = _$AsCamelCaseDocumentReference; DocumentReference get reference; @@ -10329,10 +10513,7 @@ abstract class AsCamelCaseDocumentReference extends FirestoreDocumentReference< /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -10346,11 +10527,7 @@ abstract class AsCamelCaseDocumentReference extends FirestoreDocumentReference< /// 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, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } class _$AsCamelCaseDocumentReference @@ -10452,8 +10629,10 @@ class _$AsCamelCaseDocumentReference ); final json = { if (value != _sentinel) - _$AsCamelCaseFieldMap['value']!: - _$AsCamelCasePerFieldToJson.value(value as num), + _$AsCamelCaseFieldMap['value']!: _$AsCamelCasePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; @@ -10472,8 +10651,10 @@ class _$AsCamelCaseDocumentReference ); final json = { if (value != _sentinel) - _$AsCamelCaseFieldMap['value']!: - _$AsCamelCasePerFieldToJson.value(value as num), + _$AsCamelCaseFieldMap['value']!: _$AsCamelCasePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; @@ -10492,8 +10673,10 @@ class _$AsCamelCaseDocumentReference ); final json = { if (value != _sentinel) - _$AsCamelCaseFieldMap['value']!: - _$AsCamelCasePerFieldToJson.value(value as num), + _$AsCamelCaseFieldMap['value']!: _$AsCamelCasePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$AsCamelCaseFieldMap['value']!: valueFieldValue, }; @@ -10643,17 +10826,17 @@ class _$AsCamelCaseQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(AsCamelCaseQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + AsCamelCaseQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -10710,7 +10893,8 @@ class _$AsCamelCaseQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -10742,7 +10926,8 @@ class _$AsCamelCaseQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -10785,9 +10970,11 @@ class _$AsCamelCaseQuery ? _$AsCamelCasePerFieldToJson.value(isGreaterThanOrEqualTo as num) : null, whereIn: whereIn?.map((e) => _$AsCamelCasePerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$AsCamelCasePerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$AsCamelCasePerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -10808,8 +10995,10 @@ class _$AsCamelCaseQuery AsCamelCaseDocumentSnapshot? endBeforeDocument, AsCamelCaseDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -10881,8 +11070,10 @@ class _$AsCamelCaseQuery AsCamelCaseDocumentSnapshot? endBeforeDocument, AsCamelCaseDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -10954,8 +11145,10 @@ class _$AsCamelCaseQuery AsCamelCaseDocumentSnapshot? endBeforeDocument, AsCamelCaseDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$AsCamelCaseFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$AsCamelCaseFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -10987,7 +11180,7 @@ class _$AsCamelCaseQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$AsCamelCasePerFieldToJson.value(startAt as num) + _$AsCamelCasePerFieldToJson.value(startAt as num), ], startAtDocumentSnapshot: null, ); @@ -10996,7 +11189,7 @@ class _$AsCamelCaseQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$AsCamelCasePerFieldToJson.value(startAfter as num) + _$AsCamelCasePerFieldToJson.value(startAfter as num), ], startAfterDocumentSnapshot: null, ); @@ -11005,7 +11198,7 @@ class _$AsCamelCaseQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$AsCamelCasePerFieldToJson.value(endAt as num) + _$AsCamelCasePerFieldToJson.value(endAt as num), ], endAtDocumentSnapshot: null, ); @@ -11014,7 +11207,7 @@ class _$AsCamelCaseQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$AsCamelCasePerFieldToJson.value(endBefore as num) + _$AsCamelCasePerFieldToJson.value(endBefore as num), ], endBeforeDocumentSnapshot: null, ); @@ -11047,22 +11240,17 @@ class AsCamelCaseDocumentSnapshot @override AsCamelCaseDocumentReference get reference { - return AsCamelCaseDocumentReference( - snapshot.reference, - ); + return AsCamelCaseDocumentReference(snapshot.reference); } @override final AsCamelCase? data; } -class AsCamelCaseQuerySnapshot extends FirestoreQuerySnapshot { - AsCamelCaseQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +class AsCamelCaseQuerySnapshot + extends + FirestoreQuerySnapshot { + AsCamelCaseQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory AsCamelCaseQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -11070,21 +11258,14 @@ class AsCamelCaseQuerySnapshot extends FirestoreQuerySnapshot - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, AsCamelCaseDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -11128,11 +11309,12 @@ class AsCamelCaseQueryDocumentSnapshot abstract class CustomSubNameCollectionReference implements CustomSubNameQuery, - FirestoreCollectionReference { - factory CustomSubNameCollectionReference( - DocumentReference parent, - ) = _$CustomSubNameCollectionReference; + FirestoreCollectionReference< + CustomSubName, + CustomSubNameQuerySnapshot + > { + factory CustomSubNameCollectionReference(DocumentReference parent) = + _$CustomSubNameCollectionReference; static CustomSubName fromFirestore( DocumentSnapshot> snapshot, @@ -11164,12 +11346,12 @@ abstract class CustomSubNameCollectionReference class _$CustomSubNameCollectionReference extends _$CustomSubNameQuery implements CustomSubNameCollectionReference { - factory _$CustomSubNameCollectionReference( - DocumentReference parent, - ) { + factory _$CustomSubNameCollectionReference(DocumentReference parent) { return _$CustomSubNameCollectionReference._( RootDocumentReference(parent), - parent.collection('custom-sub-name').withConverter( + parent + .collection('custom-sub-name') + .withConverter( fromFirestore: CustomSubNameCollectionReference.fromFirestore, toFirestore: CustomSubNameCollectionReference.toFirestore, ), @@ -11196,9 +11378,7 @@ class _$CustomSubNameCollectionReference extends _$CustomSubNameQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return CustomSubNameDocumentReference( - reference.doc(id), - ); + return CustomSubNameDocumentReference(reference.doc(id)); } @override @@ -11220,11 +11400,14 @@ class _$CustomSubNameCollectionReference extends _$CustomSubNameQuery } abstract class CustomSubNameDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + CustomSubName, + CustomSubNameDocumentSnapshot + > { factory CustomSubNameDocumentReference( - DocumentReference reference) = - _$CustomSubNameDocumentReference; + DocumentReference reference, + ) = _$CustomSubNameDocumentReference; DocumentReference get reference; @@ -11293,10 +11476,7 @@ abstract class CustomSubNameDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -11310,16 +11490,13 @@ abstract class CustomSubNameDocumentReference /// 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, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } -class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< - CustomSubName, - CustomSubNameDocumentSnapshot> implements CustomSubNameDocumentReference { +class _$CustomSubNameDocumentReference + extends + FirestoreDocumentReference + implements CustomSubNameDocumentReference { _$CustomSubNameDocumentReference(this.reference); @override @@ -11347,7 +11524,8 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(CustomSubNameDocumentSnapshot._); } @@ -11417,8 +11595,10 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomSubNameFieldMap['value']!: - _$CustomSubNamePerFieldToJson.value(value as num), + _$CustomSubNameFieldMap['value']!: _$CustomSubNamePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$CustomSubNameFieldMap['value']!: valueFieldValue, }; @@ -11437,8 +11617,10 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomSubNameFieldMap['value']!: - _$CustomSubNamePerFieldToJson.value(value as num), + _$CustomSubNameFieldMap['value']!: _$CustomSubNamePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$CustomSubNameFieldMap['value']!: valueFieldValue, }; @@ -11457,8 +11639,10 @@ class _$CustomSubNameDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomSubNameFieldMap['value']!: - _$CustomSubNamePerFieldToJson.value(value as num), + _$CustomSubNameFieldMap['value']!: _$CustomSubNamePerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$CustomSubNameFieldMap['value']!: valueFieldValue, }; @@ -11608,17 +11792,17 @@ class _$CustomSubNameQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(CustomSubNameQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + CustomSubNameQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -11675,7 +11859,8 @@ class _$CustomSubNameQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -11707,7 +11892,8 @@ class _$CustomSubNameQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -11750,9 +11936,11 @@ class _$CustomSubNameQuery ? _$CustomSubNamePerFieldToJson.value(isGreaterThanOrEqualTo as num) : null, whereIn: whereIn?.map((e) => _$CustomSubNamePerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$CustomSubNamePerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$CustomSubNamePerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -11773,8 +11961,10 @@ class _$CustomSubNameQuery CustomSubNameDocumentSnapshot? endBeforeDocument, CustomSubNameDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -11846,8 +12036,10 @@ class _$CustomSubNameQuery CustomSubNameDocumentSnapshot? endBeforeDocument, CustomSubNameDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -11919,8 +12111,10 @@ class _$CustomSubNameQuery CustomSubNameDocumentSnapshot? endBeforeDocument, CustomSubNameDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$CustomSubNameFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$CustomSubNameFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -11952,7 +12146,7 @@ class _$CustomSubNameQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$CustomSubNamePerFieldToJson.value(startAt as num) + _$CustomSubNamePerFieldToJson.value(startAt as num), ], startAtDocumentSnapshot: null, ); @@ -11961,7 +12155,7 @@ class _$CustomSubNameQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$CustomSubNamePerFieldToJson.value(startAfter as num) + _$CustomSubNamePerFieldToJson.value(startAfter as num), ], startAfterDocumentSnapshot: null, ); @@ -11970,7 +12164,7 @@ class _$CustomSubNameQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$CustomSubNamePerFieldToJson.value(endAt as num) + _$CustomSubNamePerFieldToJson.value(endAt as num), ], endAtDocumentSnapshot: null, ); @@ -11979,7 +12173,7 @@ class _$CustomSubNameQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$CustomSubNamePerFieldToJson.value(endBefore as num) + _$CustomSubNamePerFieldToJson.value(endBefore as num), ], endBeforeDocumentSnapshot: null, ); @@ -12012,45 +12206,37 @@ class CustomSubNameDocumentSnapshot @override CustomSubNameDocumentReference get reference { - return CustomSubNameDocumentReference( - snapshot.reference, - ); + return CustomSubNameDocumentReference(snapshot.reference); } @override final CustomSubName? data; } -class CustomSubNameQuerySnapshot extends FirestoreQuerySnapshot { - CustomSubNameQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(CustomSubNameQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - CustomSubNameDocumentSnapshot._, - ); + return _decodeDocumentChange(change, CustomSubNameDocumentSnapshot._); }).toList(); - return CustomSubNameQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return CustomSubNameQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, CustomSubNameDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -12094,8 +12280,10 @@ class CustomSubNameQueryDocumentSnapshot abstract class ThisIsACustomPrefixCollectionReference implements ThisIsACustomPrefixQuery, - FirestoreCollectionReference { + FirestoreCollectionReference< + CustomClassPrefix, + ThisIsACustomPrefixQuerySnapshot + > { factory ThisIsACustomPrefixCollectionReference( DocumentReference parent, ) = _$ThisIsACustomPrefixCollectionReference; @@ -12136,7 +12324,9 @@ class _$ThisIsACustomPrefixCollectionReference ) { return _$ThisIsACustomPrefixCollectionReference._( RootDocumentReference(parent), - parent.collection('custom-class-prefix').withConverter( + parent + .collection('custom-class-prefix') + .withConverter( fromFirestore: ThisIsACustomPrefixCollectionReference.fromFirestore, toFirestore: ThisIsACustomPrefixCollectionReference.toFirestore, ), @@ -12163,9 +12353,7 @@ class _$ThisIsACustomPrefixCollectionReference id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ThisIsACustomPrefixDocumentReference( - reference.doc(id), - ); + return ThisIsACustomPrefixDocumentReference(reference.doc(id)); } @override @@ -12187,11 +12375,14 @@ class _$ThisIsACustomPrefixCollectionReference } abstract class ThisIsACustomPrefixDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + CustomClassPrefix, + ThisIsACustomPrefixDocumentSnapshot + > { factory ThisIsACustomPrefixDocumentReference( - DocumentReference reference) = - _$ThisIsACustomPrefixDocumentReference; + DocumentReference reference, + ) = _$ThisIsACustomPrefixDocumentReference; DocumentReference get reference; @@ -12260,10 +12451,7 @@ abstract class ThisIsACustomPrefixDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -12277,15 +12465,15 @@ abstract class ThisIsACustomPrefixDocumentReference /// 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, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } -class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< - CustomClassPrefix, ThisIsACustomPrefixDocumentSnapshot> +class _$ThisIsACustomPrefixDocumentReference + extends + FirestoreDocumentReference< + CustomClassPrefix, + ThisIsACustomPrefixDocumentSnapshot + > implements ThisIsACustomPrefixDocumentReference { _$ThisIsACustomPrefixDocumentReference(this.reference); @@ -12314,7 +12502,8 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction .get(reference) .then(ThisIsACustomPrefixDocumentSnapshot._); @@ -12386,8 +12575,9 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomClassPrefixFieldMap['value']!: - _$CustomClassPrefixPerFieldToJson.value(value as num), + _$CustomClassPrefixFieldMap['value']!: _$CustomClassPrefixPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; @@ -12406,8 +12596,9 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomClassPrefixFieldMap['value']!: - _$CustomClassPrefixPerFieldToJson.value(value as num), + _$CustomClassPrefixFieldMap['value']!: _$CustomClassPrefixPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; @@ -12426,8 +12617,9 @@ class _$ThisIsACustomPrefixDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$CustomClassPrefixFieldMap['value']!: - _$CustomClassPrefixPerFieldToJson.value(value as num), + _$CustomClassPrefixFieldMap['value']!: _$CustomClassPrefixPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$CustomClassPrefixFieldMap['value']!: valueFieldValue, }; @@ -12578,18 +12770,19 @@ class _$ThisIsACustomPrefixQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override - Stream snapshots( - [SnapshotOptions? options]) { - return reference - .snapshots() - .map(ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot); + Stream snapshots([ + SnapshotOptions? options, + ]) { + return reference.snapshots().map( + ThisIsACustomPrefixQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -12646,7 +12839,8 @@ class _$ThisIsACustomPrefixQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -12678,7 +12872,8 @@ class _$ThisIsACustomPrefixQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -12712,21 +12907,26 @@ class _$ThisIsACustomPrefixQuery ? _$CustomClassPrefixPerFieldToJson.value(isLessThan as num) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$CustomClassPrefixPerFieldToJson - .value(isLessThanOrEqualTo as num) + ? _$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 ?? + ? _$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), ), @@ -12747,8 +12947,10 @@ class _$ThisIsACustomPrefixQuery ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -12820,8 +13022,10 @@ class _$ThisIsACustomPrefixQuery ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -12893,8 +13097,10 @@ class _$ThisIsACustomPrefixQuery ThisIsACustomPrefixDocumentSnapshot? endBeforeDocument, ThisIsACustomPrefixDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$CustomClassPrefixFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$CustomClassPrefixFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -12926,7 +13132,7 @@ class _$ThisIsACustomPrefixQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$CustomClassPrefixPerFieldToJson.value(startAt as num) + _$CustomClassPrefixPerFieldToJson.value(startAt as num), ], startAtDocumentSnapshot: null, ); @@ -12935,7 +13141,7 @@ class _$ThisIsACustomPrefixQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$CustomClassPrefixPerFieldToJson.value(startAfter as num) + _$CustomClassPrefixPerFieldToJson.value(startAfter as num), ], startAfterDocumentSnapshot: null, ); @@ -12944,7 +13150,7 @@ class _$ThisIsACustomPrefixQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$CustomClassPrefixPerFieldToJson.value(endAt as num) + _$CustomClassPrefixPerFieldToJson.value(endAt as num), ], endAtDocumentSnapshot: null, ); @@ -12953,7 +13159,7 @@ class _$ThisIsACustomPrefixQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$CustomClassPrefixPerFieldToJson.value(endBefore as num) + _$CustomClassPrefixPerFieldToJson.value(endBefore as num), ], endBeforeDocumentSnapshot: null, ); @@ -12986,28 +13192,27 @@ class ThisIsACustomPrefixDocumentSnapshot @override ThisIsACustomPrefixDocumentReference get reference { - return ThisIsACustomPrefixDocumentReference( - snapshot.reference, - ); + return ThisIsACustomPrefixDocumentReference(snapshot.reference); } @override final CustomClassPrefix? data; } -class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< - CustomClassPrefix, ThisIsACustomPrefixQueryDocumentSnapshot> { - ThisIsACustomPrefixQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(ThisIsACustomPrefixQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { return _decodeDocumentChange( @@ -13016,18 +13221,14 @@ class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< ); }).toList(); - return ThisIsACustomPrefixQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ThisIsACustomPrefixQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ThisIsACustomPrefixDocumentSnapshot Function(DocumentSnapshot doc) - decodeDoc, + decodeDoc, ) { return FirestoreDocumentChange( type: docChange.type, @@ -13044,14 +13245,14 @@ class ThisIsACustomPrefixQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class ThisIsACustomPrefixQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements ThisIsACustomPrefixDocumentSnapshot { ThisIsACustomPrefixQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -13072,9 +13273,8 @@ abstract class ExplicitPathCollectionReference implements ExplicitPathQuery, FirestoreCollectionReference { - factory ExplicitPathCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$ExplicitPathCollectionReference; + factory ExplicitPathCollectionReference([FirebaseFirestore? firestore]) = + _$ExplicitPathCollectionReference; static ExplicitPath fromFirestore( DocumentSnapshot> snapshot, @@ -13107,7 +13307,9 @@ class _$ExplicitPathCollectionReference extends _$ExplicitPathQuery firestore ??= FirebaseFirestore.instance; return _$ExplicitPathCollectionReference._( - firestore.collection('root/doc/path').withConverter( + firestore + .collection('root/doc/path') + .withConverter( fromFirestore: ExplicitPathCollectionReference.fromFirestore, toFirestore: ExplicitPathCollectionReference.toFirestore, ), @@ -13130,9 +13332,7 @@ class _$ExplicitPathCollectionReference extends _$ExplicitPathQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ExplicitPathDocumentReference( - reference.doc(id), - ); + return ExplicitPathDocumentReference(reference.doc(id)); } @override @@ -13153,11 +13353,12 @@ class _$ExplicitPathCollectionReference extends _$ExplicitPathQuery int get hashCode => Object.hash(runtimeType, reference); } -abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< - ExplicitPath, ExplicitPathDocumentSnapshot> { +abstract class ExplicitPathDocumentReference + extends + FirestoreDocumentReference { factory ExplicitPathDocumentReference( - DocumentReference reference) = - _$ExplicitPathDocumentReference; + DocumentReference reference, + ) = _$ExplicitPathDocumentReference; DocumentReference get reference; @@ -13167,9 +13368,7 @@ abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< } late final ExplicitSubPathCollectionReference sub = - _$ExplicitSubPathCollectionReference( - reference, - ); + _$ExplicitSubPathCollectionReference(reference); @override Stream snapshots(); @@ -13226,10 +13425,7 @@ abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -13243,16 +13439,13 @@ abstract class ExplicitPathDocumentReference extends FirestoreDocumentReference< /// 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, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } -class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< - ExplicitPath, - ExplicitPathDocumentSnapshot> implements ExplicitPathDocumentReference { +class _$ExplicitPathDocumentReference + extends + FirestoreDocumentReference + implements ExplicitPathDocumentReference { _$ExplicitPathDocumentReference(this.reference); @override @@ -13264,9 +13457,7 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< } late final ExplicitSubPathCollectionReference sub = - _$ExplicitSubPathCollectionReference( - reference, - ); + _$ExplicitSubPathCollectionReference(reference); @override Stream snapshots() { @@ -13349,8 +13540,10 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitPathFieldMap['value']!: - _$ExplicitPathPerFieldToJson.value(value as num), + _$ExplicitPathFieldMap['value']!: _$ExplicitPathPerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$ExplicitPathFieldMap['value']!: valueFieldValue, }; @@ -13369,8 +13562,10 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitPathFieldMap['value']!: - _$ExplicitPathPerFieldToJson.value(value as num), + _$ExplicitPathFieldMap['value']!: _$ExplicitPathPerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$ExplicitPathFieldMap['value']!: valueFieldValue, }; @@ -13389,8 +13584,10 @@ class _$ExplicitPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitPathFieldMap['value']!: - _$ExplicitPathPerFieldToJson.value(value as num), + _$ExplicitPathFieldMap['value']!: _$ExplicitPathPerFieldToJson.value( + value as num, + ), + if (valueFieldValue != null) _$ExplicitPathFieldMap['value']!: valueFieldValue, }; @@ -13540,17 +13737,17 @@ class _$ExplicitPathQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(ExplicitPathQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + ExplicitPathQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -13607,7 +13804,8 @@ class _$ExplicitPathQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -13639,7 +13837,8 @@ class _$ExplicitPathQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -13682,9 +13881,11 @@ class _$ExplicitPathQuery ? _$ExplicitPathPerFieldToJson.value(isGreaterThanOrEqualTo as num) : null, whereIn: whereIn?.map((e) => _$ExplicitPathPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$ExplicitPathPerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$ExplicitPathPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -13705,8 +13906,10 @@ class _$ExplicitPathQuery ExplicitPathDocumentSnapshot? endBeforeDocument, ExplicitPathDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -13778,8 +13981,10 @@ class _$ExplicitPathQuery ExplicitPathDocumentSnapshot? endBeforeDocument, ExplicitPathDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -13851,8 +14056,10 @@ class _$ExplicitPathQuery ExplicitPathDocumentSnapshot? endBeforeDocument, ExplicitPathDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$ExplicitPathFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$ExplicitPathFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -13884,7 +14091,7 @@ class _$ExplicitPathQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$ExplicitPathPerFieldToJson.value(startAt as num) + _$ExplicitPathPerFieldToJson.value(startAt as num), ], startAtDocumentSnapshot: null, ); @@ -13893,7 +14100,7 @@ class _$ExplicitPathQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$ExplicitPathPerFieldToJson.value(startAfter as num) + _$ExplicitPathPerFieldToJson.value(startAfter as num), ], startAfterDocumentSnapshot: null, ); @@ -13902,7 +14109,7 @@ class _$ExplicitPathQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$ExplicitPathPerFieldToJson.value(endAt as num) + _$ExplicitPathPerFieldToJson.value(endAt as num), ], endAtDocumentSnapshot: null, ); @@ -13911,7 +14118,7 @@ class _$ExplicitPathQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$ExplicitPathPerFieldToJson.value(endBefore as num) + _$ExplicitPathPerFieldToJson.value(endBefore as num), ], endBeforeDocumentSnapshot: null, ); @@ -13944,45 +14151,37 @@ class ExplicitPathDocumentSnapshot @override ExplicitPathDocumentReference get reference { - return ExplicitPathDocumentReference( - snapshot.reference, - ); + return ExplicitPathDocumentReference(snapshot.reference); } @override final ExplicitPath? data; } -class ExplicitPathQuerySnapshot extends FirestoreQuerySnapshot { - ExplicitPathQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(ExplicitPathQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ExplicitPathDocumentSnapshot._, - ); + return _decodeDocumentChange(change, ExplicitPathDocumentSnapshot._); }).toList(); - return ExplicitPathQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ExplicitPathQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ExplicitPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -14026,8 +14225,10 @@ class ExplicitPathQueryDocumentSnapshot abstract class ExplicitSubPathCollectionReference implements ExplicitSubPathQuery, - FirestoreCollectionReference { + FirestoreCollectionReference< + ExplicitSubPath, + ExplicitSubPathQuerySnapshot + > { factory ExplicitSubPathCollectionReference( DocumentReference parent, ) = _$ExplicitSubPathCollectionReference; @@ -14067,7 +14268,9 @@ class _$ExplicitSubPathCollectionReference extends _$ExplicitSubPathQuery ) { return _$ExplicitSubPathCollectionReference._( ExplicitPathDocumentReference(parent), - parent.collection('sub').withConverter( + parent + .collection('sub') + .withConverter( fromFirestore: ExplicitSubPathCollectionReference.fromFirestore, toFirestore: ExplicitSubPathCollectionReference.toFirestore, ), @@ -14094,9 +14297,7 @@ class _$ExplicitSubPathCollectionReference extends _$ExplicitSubPathQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return ExplicitSubPathDocumentReference( - reference.doc(id), - ); + return ExplicitSubPathDocumentReference(reference.doc(id)); } @override @@ -14118,11 +14319,14 @@ class _$ExplicitSubPathCollectionReference extends _$ExplicitSubPathQuery } abstract class ExplicitSubPathDocumentReference - extends FirestoreDocumentReference { + extends + FirestoreDocumentReference< + ExplicitSubPath, + ExplicitSubPathDocumentSnapshot + > { factory ExplicitSubPathDocumentReference( - DocumentReference reference) = - _$ExplicitSubPathDocumentReference; + DocumentReference reference, + ) = _$ExplicitSubPathDocumentReference; DocumentReference get reference; @@ -14191,10 +14395,7 @@ abstract class ExplicitSubPathDocumentReference /// document data. /// /// If no document exists yet, the update will fail. - Future update({ - num value, - FieldValue valueFieldValue, - }); + Future update({num value, FieldValue valueFieldValue}); /// Updates fields in the current document using the transaction API. /// @@ -14208,15 +14409,15 @@ abstract class ExplicitSubPathDocumentReference /// 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, - }); + void batchUpdate(WriteBatch batch, {num value, FieldValue valueFieldValue}); } -class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< - ExplicitSubPath, ExplicitSubPathDocumentSnapshot> +class _$ExplicitSubPathDocumentReference + extends + FirestoreDocumentReference< + ExplicitSubPath, + ExplicitSubPathDocumentSnapshot + > implements ExplicitSubPathDocumentReference { _$ExplicitSubPathDocumentReference(this.reference); @@ -14245,7 +14446,8 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< @override Future transactionGet( - Transaction transaction) { + Transaction transaction, + ) { return transaction.get(reference).then(ExplicitSubPathDocumentSnapshot._); } @@ -14315,8 +14517,9 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitSubPathFieldMap['value']!: - _$ExplicitSubPathPerFieldToJson.value(value as num), + _$ExplicitSubPathFieldMap['value']!: _$ExplicitSubPathPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; @@ -14335,8 +14538,9 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitSubPathFieldMap['value']!: - _$ExplicitSubPathPerFieldToJson.value(value as num), + _$ExplicitSubPathFieldMap['value']!: _$ExplicitSubPathPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; @@ -14355,8 +14559,9 @@ class _$ExplicitSubPathDocumentReference extends FirestoreDocumentReference< ); final json = { if (value != _sentinel) - _$ExplicitSubPathFieldMap['value']!: - _$ExplicitSubPathPerFieldToJson.value(value as num), + _$ExplicitSubPathFieldMap['value']!: _$ExplicitSubPathPerFieldToJson + .value(value as num), + if (valueFieldValue != null) _$ExplicitSubPathFieldMap['value']!: valueFieldValue, }; @@ -14506,17 +14711,17 @@ class _$ExplicitSubPathQuery required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @override Stream snapshots([SnapshotOptions? options]) { - return reference - .snapshots() - .map(ExplicitSubPathQuerySnapshot._fromQuerySnapshot); + return reference.snapshots().map( + ExplicitSubPathQuerySnapshot._fromQuerySnapshot, + ); } @override @@ -14573,7 +14778,8 @@ class _$ExplicitSubPathQuery arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -14605,7 +14811,8 @@ class _$ExplicitSubPathQuery isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -14645,13 +14852,16 @@ class _$ExplicitSubPathQuery ? _$ExplicitSubPathPerFieldToJson.value(isGreaterThan as num) : null, isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$ExplicitSubPathPerFieldToJson - .value(isGreaterThanOrEqualTo as num) + ? _$ExplicitSubPathPerFieldToJson.value( + isGreaterThanOrEqualTo as num, + ) : null, whereIn: whereIn?.map((e) => _$ExplicitSubPathPerFieldToJson.value(e)), - whereNotIn: - whereNotIn?.map((e) => _$ExplicitSubPathPerFieldToJson.value(e)), - isNull: isNull ?? + whereNotIn: whereNotIn?.map( + (e) => _$ExplicitSubPathPerFieldToJson.value(e), + ), + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -14672,8 +14882,10 @@ class _$ExplicitSubPathQuery ExplicitSubPathDocumentSnapshot? endBeforeDocument, ExplicitSubPathDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -14745,8 +14957,10 @@ class _$ExplicitSubPathQuery ExplicitSubPathDocumentSnapshot? endBeforeDocument, ExplicitSubPathDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -14818,8 +15032,10 @@ class _$ExplicitSubPathQuery ExplicitSubPathDocumentSnapshot? endBeforeDocument, ExplicitSubPathDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$ExplicitSubPathFieldMap['value']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$ExplicitSubPathFieldMap['value']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -14851,7 +15067,7 @@ class _$ExplicitSubPathQuery queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$ExplicitSubPathPerFieldToJson.value(startAt as num) + _$ExplicitSubPathPerFieldToJson.value(startAt as num), ], startAtDocumentSnapshot: null, ); @@ -14860,7 +15076,7 @@ class _$ExplicitSubPathQuery queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$ExplicitSubPathPerFieldToJson.value(startAfter as num) + _$ExplicitSubPathPerFieldToJson.value(startAfter as num), ], startAfterDocumentSnapshot: null, ); @@ -14869,7 +15085,7 @@ class _$ExplicitSubPathQuery queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$ExplicitSubPathPerFieldToJson.value(endAt as num) + _$ExplicitSubPathPerFieldToJson.value(endAt as num), ], endAtDocumentSnapshot: null, ); @@ -14878,7 +15094,7 @@ class _$ExplicitSubPathQuery queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$ExplicitSubPathPerFieldToJson.value(endBefore as num) + _$ExplicitSubPathPerFieldToJson.value(endBefore as num), ], endBeforeDocumentSnapshot: null, ); @@ -14911,45 +15127,37 @@ class ExplicitSubPathDocumentSnapshot @override ExplicitSubPathDocumentReference get reference { - return ExplicitSubPathDocumentReference( - snapshot.reference, - ); + return ExplicitSubPathDocumentReference(snapshot.reference); } @override final ExplicitSubPath? data; } -class ExplicitSubPathQuerySnapshot extends FirestoreQuerySnapshot< - ExplicitSubPath, ExplicitSubPathQueryDocumentSnapshot> { - ExplicitSubPathQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); +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 docs = snapshot.docs + .map(ExplicitSubPathQueryDocumentSnapshot._) + .toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - ExplicitSubPathDocumentSnapshot._, - ); + return _decodeDocumentChange(change, ExplicitSubPathDocumentSnapshot._); }).toList(); - return ExplicitSubPathQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return ExplicitSubPathQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, ExplicitSubPathDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -14968,14 +15176,14 @@ class ExplicitSubPathQuerySnapshot extends FirestoreQuerySnapshot< @override final List> - docChanges; + docChanges; } class ExplicitSubPathQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot implements ExplicitSubPathDocumentSnapshot { ExplicitSubPathQueryDocumentSnapshot._(this.snapshot) - : data = snapshot.data(); + : data = snapshot.data(); @override final QueryDocumentSnapshot snapshot; @@ -14996,9 +15204,8 @@ abstract class SubClassCollectionReference implements SubClassQuery, FirestoreCollectionReference { - factory SubClassCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$SubClassCollectionReference; + factory SubClassCollectionReference([FirebaseFirestore? firestore]) = + _$SubClassCollectionReference; static SubClass fromFirestore( DocumentSnapshot> snapshot, @@ -15007,10 +15214,7 @@ abstract class SubClassCollectionReference return SubClass.fromJson(snapshot.data()!); } - static Map toFirestore( - SubClass value, - SetOptions? options, - ) { + static Map toFirestore(SubClass value, SetOptions? options) { return value.toJson(); } @@ -15031,16 +15235,17 @@ class _$SubClassCollectionReference extends _$SubClassQuery firestore ??= FirebaseFirestore.instance; return _$SubClassCollectionReference._( - firestore.collection('root').withConverter( + firestore + .collection('root') + .withConverter( fromFirestore: SubClassCollectionReference.fromFirestore, toFirestore: SubClassCollectionReference.toFirestore, ), ); } - _$SubClassCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); + _$SubClassCollectionReference._(CollectionReference reference) + : super(reference, $referenceWithoutCursor: reference); String get path => reference.path; @@ -15054,9 +15259,7 @@ class _$SubClassCollectionReference extends _$SubClassQuery id == null || id.split('/').length == 1, 'The document ID cannot be from a different collection', ); - return SubClassDocumentReference( - reference.doc(id), - ); + return SubClassDocumentReference(reference.doc(id)); } @override @@ -15260,8 +15463,9 @@ class _$SubClassDocumentReference ); final json = { if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + if (instanceGetterFieldValue != null) _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; @@ -15280,8 +15484,9 @@ class _$SubClassDocumentReference ); final json = { if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + if (instanceGetterFieldValue != null) _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; @@ -15300,8 +15505,9 @@ class _$SubClassDocumentReference ); final json = { if (instanceGetter != _sentinel) - _$SubClassFieldMap['instanceGetter']!: - _$SubClassPerFieldToJson.instanceGetter(instanceGetter as int), + _$SubClassFieldMap['instanceGetter']!: _$SubClassPerFieldToJson + .instanceGetter(instanceGetter as int), + if (instanceGetterFieldValue != null) _$SubClassFieldMap['instanceGetter']!: instanceGetterFieldValue, }; @@ -15450,9 +15656,9 @@ class _$SubClassQuery extends QueryReference required Query $referenceWithoutCursor, $QueryCursor $queryCursor = const $QueryCursor(), }) : super( - $referenceWithoutCursor: $referenceWithoutCursor, - $queryCursor: $queryCursor, - ); + $referenceWithoutCursor: $referenceWithoutCursor, + $queryCursor: $queryCursor, + ); final CollectionReference _collection; @@ -15515,7 +15721,8 @@ class _$SubClassQuery extends QueryReference arrayContainsAny: arrayContainsAny, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -15547,7 +15754,8 @@ class _$SubClassQuery extends QueryReference isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, whereIn: whereIn, whereNotIn: whereNotIn, - isNull: isNull ?? + isNull: + isNull ?? (isEqualTo == null ? false : null) ?? (isNotEqualTo == null ? true : null), ), @@ -15581,21 +15789,26 @@ class _$SubClassQuery extends QueryReference ? _$SubClassPerFieldToJson.instanceGetter(isLessThan as int) : null, isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$SubClassPerFieldToJson - .instanceGetter(isLessThanOrEqualTo as int) + ? _$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 ?? + ? _$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), ), @@ -15616,8 +15829,10 @@ class _$SubClassQuery extends QueryReference SubClassDocumentSnapshot? endBeforeDocument, SubClassDocumentSnapshot? startAfterDocument, }) { - final query = - $referenceWithoutCursor.orderBy(fieldPath, descending: descending); + final query = $referenceWithoutCursor.orderBy( + fieldPath, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -15689,8 +15904,10 @@ class _$SubClassQuery extends QueryReference SubClassDocumentSnapshot? endBeforeDocument, SubClassDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor.orderBy(FieldPath.documentId, - descending: descending); + final query = $referenceWithoutCursor.orderBy( + FieldPath.documentId, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -15762,8 +15979,10 @@ class _$SubClassQuery extends QueryReference SubClassDocumentSnapshot? endBeforeDocument, SubClassDocumentSnapshot? startAfterDocument, }) { - final query = $referenceWithoutCursor - .orderBy(_$SubClassFieldMap['instanceGetter']!, descending: descending); + final query = $referenceWithoutCursor.orderBy( + _$SubClassFieldMap['instanceGetter']!, + descending: descending, + ); var queryCursor = $queryCursor; if (startAtDocument != null) { @@ -15795,7 +16014,7 @@ class _$SubClassQuery extends QueryReference queryCursor = queryCursor.copyWith( startAt: [ ...queryCursor.startAt, - _$SubClassPerFieldToJson.instanceGetter(startAt as int) + _$SubClassPerFieldToJson.instanceGetter(startAt as int), ], startAtDocumentSnapshot: null, ); @@ -15804,7 +16023,7 @@ class _$SubClassQuery extends QueryReference queryCursor = queryCursor.copyWith( startAfter: [ ...queryCursor.startAfter, - _$SubClassPerFieldToJson.instanceGetter(startAfter as int) + _$SubClassPerFieldToJson.instanceGetter(startAfter as int), ], startAfterDocumentSnapshot: null, ); @@ -15813,7 +16032,7 @@ class _$SubClassQuery extends QueryReference queryCursor = queryCursor.copyWith( endAt: [ ...queryCursor.endAt, - _$SubClassPerFieldToJson.instanceGetter(endAt as int) + _$SubClassPerFieldToJson.instanceGetter(endAt as int), ], endAtDocumentSnapshot: null, ); @@ -15822,7 +16041,7 @@ class _$SubClassQuery extends QueryReference queryCursor = queryCursor.copyWith( endBefore: [ ...queryCursor.endBefore, - _$SubClassPerFieldToJson.instanceGetter(endBefore as int) + _$SubClassPerFieldToJson.instanceGetter(endBefore as int), ], endBeforeDocumentSnapshot: null, ); @@ -15854,9 +16073,7 @@ class SubClassDocumentSnapshot extends FirestoreDocumentSnapshot { @override SubClassDocumentReference get reference { - return SubClassDocumentReference( - snapshot.reference, - ); + return SubClassDocumentReference(snapshot.reference); } @override @@ -15865,11 +16082,7 @@ class SubClassDocumentSnapshot extends FirestoreDocumentSnapshot { class SubClassQuerySnapshot extends FirestoreQuerySnapshot { - SubClassQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); + SubClassQuerySnapshot._(this.snapshot, this.docs, this.docChanges); factory SubClassQuerySnapshot._fromQuerySnapshot( QuerySnapshot snapshot, @@ -15877,21 +16090,14 @@ class SubClassQuerySnapshot final docs = snapshot.docs.map(SubClassQueryDocumentSnapshot._).toList(); final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - SubClassDocumentSnapshot._, - ); + return _decodeDocumentChange(change, SubClassDocumentSnapshot._); }).toList(); - return SubClassQuerySnapshot._( - snapshot, - docs, - docChanges, - ); + return SubClassQuerySnapshot._(snapshot, docs, docChanges); } static FirestoreDocumentChange - _decodeDocumentChange( + _decodeDocumentChange( DocumentChange docChange, SubClassDocumentSnapshot Function(DocumentSnapshot doc) decodeDoc, ) { @@ -15945,9 +16151,7 @@ void _$assertMinValidation(MinValidation instance) { // ************************************************************************** IgnoredGetter _$IgnoredGetterFromJson(Map json) => - IgnoredGetter( - (json['value'] as num).toInt(), - ); + IgnoredGetter((json['value'] as num).toInt()); const _$IgnoredGetterFieldMap = { 'value': 'value', @@ -15963,18 +16167,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 { @@ -15983,38 +16181,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', @@ -16066,21 +16265,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', @@ -16128,10 +16328,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', @@ -16147,17 +16345,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 { @@ -16166,17 +16361,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 { @@ -16185,13 +16375,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', @@ -16207,18 +16395,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 { @@ -16227,17 +16411,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 { @@ -16246,18 +16425,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 { @@ -16266,17 +16439,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 { @@ -16285,18 +16453,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 { @@ -16305,17 +16467,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 { @@ -16324,5 +16481,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 c360b38..4db0592 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,27 +2,27 @@ name: cloud_firestore_odm_generator_integration_test publish_to: none environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" dependencies: cloud_firestore: ^6.0.0 cloud_firestore_odm: ^1.2.0 flutter: sdk: flutter - freezed_annotation: ^3.0.0 + freezed_annotation: ^3.1.0 json_annotation: ^4.9.0 meta: ^1.12.0 dev_dependencies: - build_runner: ^2.4.8 + build_runner: ^2.7.0 cloud_firestore_odm_generator: path: ../ + firebase_core_platform_interface: ^6.0.0 flutter_test: sdk: flutter - freezed: ^3.0.2 - json_serializable: ^6.9.4 - test: ^1.25.1 - firebase_core_platform_interface: ^6.0.0 + freezed: ^3.2.0 + json_serializable: ^6.11.0 + test: ^1.25.15 dependency_overrides: cloud_firestore_odm: 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 7970f35..62a7da8 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 @@ -36,8 +36,7 @@ void main() { }); 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( @@ -54,7 +53,7 @@ void main() { /// test freezed mixed mode classes group('freezed mixed mode classes', () { test('test freezed simple classes', () { - final simpleFreezed = SimpleFreezed(a: 42); + const simpleFreezed = SimpleFreezed(a: 42); expect(simpleFreezed.toJson(), {'a': 42}); final simpleFreezedFromJson = SimpleFreezed.fromJson({'a': 42}); @@ -65,8 +64,7 @@ void main() { final publicRedirected = PublicRedirected(value: 'test'); expect(publicRedirected.toJson(), {'value': 'test'}); - final publicRedirectedFromJson = - PublicRedirected.fromJson({'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/setup_firestore_mock.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/setup_firestore_mock.dart index 9bd0210..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 @@ -17,9 +17,6 @@ void setupFirestoreMocks() { } class MockFirebasePlatform extends FirebasePlatform { - @override - bool get isAutomaticDataCollectionEnabled => true; - @override Future initializeApp({ String? name, @@ -37,13 +34,14 @@ class MockFirebasePlatform extends FirebasePlatform { 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', - )); + defaultFirebaseAppName, + const FirebaseOptions( + apiKey: 'mock-api-key', + appId: 'mock-app-id', + messagingSenderId: 'mock-sender-id', + projectId: 'mock-project-id', + ), + ); @override String get name => defaultFirebaseAppName; 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 8cc9672..5df4ed8 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:analyzer/dart/constant/value.dart'; -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:cloud_firestore_odm/annotation.dart'; import 'package:collection/collection.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,15 +88,15 @@ 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, - required Element annotatedElement, + required LibraryElement2 libraryElement, + required Element2 annotatedElement, required DartObject annotation, required GlobalData globalData, }) { + print('annotation: ${annotation}'); // TODO find a way to test validation final name = annotation.getField('name')!.toStringValue(); @@ -118,8 +118,8 @@ class CollectionData with Names { ); } - final collectionTargetElement = type.element; - if (collectionTargetElement is! ClassElement) { + final collectionTargetElement = type.element3; + if (collectionTargetElement is! ClassElement2) { throw InvalidGenerationSourceError( 'The annotation @Collection can only receive classes as generic argument. ', element: annotatedElement, @@ -127,44 +127,37 @@ 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( - 'Used @Collection with the class ${collectionTargetElement.name}, but ' + 'Used @Collection with the class ${collectionTargetElement.name3}, but ' 'the class has no @JsonSerializable annotation.', ); } - final annotatedElementSource = annotatedElement.librarySource; + final annotatedElementSource = annotatedElement.library2; // 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.library2 == 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.library2} +''', element: annotatedElement); } // TODO test error handling @@ -175,17 +168,17 @@ 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.name3?.public ?? ''; + final fromJson = collectionTargetElement.constructors2.firstWhereOrNull( + (ctor) => ctor.name3 == '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 ' + '@Collection was used with the class ${collectionTargetElement.name3} but ' 'its fromJson does not match `Function(Map json)`.', element: annotatedElement, ); @@ -194,19 +187,19 @@ represents the content of the collection must be in the same file. final toJson = collectionTargetElement // Looking into fromJson from superTypes too .allMethods - .firstWhereOrNull((method) => method.name == 'toJson'); - final redirectedFreezedClass = redirectedFreezedConstructors - .singleOrNull?.redirectedConstructor!.enclosingElement3.name; + .firstWhereOrNull((method) => method.name3 == 'toJson'); + final redirectedFreezedClass = + redirectedFreezedConstructors.singleOrNull?.redirectedConstructor2!.enclosingElement2.name3; 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 ' + '@Collection was used with the class ${collectionTargetElement.name3} but ' 'its toJson does not match `Map Function()`.', element: annotatedElement, ); @@ -226,15 +219,11 @@ 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, + ?.name3, queryableFields: [ QueryingField( 'fieldPath', @@ -277,34 +266,31 @@ represents the content of the collection must be in the same file. /// ```dart /// collection.orderByTitle(startAt: 'title'); /// ```''', - annotatedElement.library!.typeProvider.objectType, + annotatedElement.library2!.typeProvider.objectType, field: 'fieldPath', updatable: false, ), QueryingField( 'documentId', - annotatedElement.library!.typeProvider.stringType, + annotatedElement.library2!.typeProvider.stringType, whereDoc: '', // Inherited orderByDoc: '', // Inherited field: 'FieldPath.documentId', 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.name3!, f.type, whereDoc: '', orderByDoc: '', updatable: true, - field: "${generatedJsonTypePrefix}FieldMap['${f.name}']!", + field: "${generatedJsonTypePrefix}FieldMap['${f.name3}']!", ), ) .toList(), @@ -313,8 +299,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,13 +308,12 @@ 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; } - static void _assertIsValidCollectionPath(String? path, Element element) { + static void _assertIsValidCollectionPath(String? path, Element2 element) { if (path == null) { throw InvalidGenerationSourceError( 'The annotation @Collection received "$path" as collection path, ' @@ -377,8 +361,7 @@ represents the content of the collection must be in the same file. required String collectionTargetElementPublicType, }) { if (hasFreezed) { - final className = - redirectedFreezedClass?.public ?? collectionTargetElementPublicType; + final className = redirectedFreezedClass?.public ?? collectionTargetElementPublicType; // Only support freezed 3.x or higher return '_\$$className'; } else { @@ -395,10 +378,9 @@ represents the content of the collection must be in the same file. final String path; final String? idKey; final List queryableFields; - final LibraryElement libraryElement; + final LibraryElement2 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; @@ -416,18 +398,18 @@ represents the content of the collection must be in the same file. } } -extension on ClassElement { - Iterable get allMethods sync* { - yield* methods; +extension on ClassElement2 { + Iterable get allMethods sync* { + yield* methods2; for (final supertype in allSupertypes) { if (supertype.isDartCoreObject) continue; - yield* supertype.methods; + yield* supertype.methods2; } } - Iterable allFields({ + Iterable allFields({ required bool hasFreezed, - required List freezedConstructors, + required List freezedConstructors, }) { if (hasFreezed) { /// For Freezed 3.x, support mixed mode classes. There can be the classic freezed way with a factory, @@ -435,29 +417,26 @@ extension on ClassElement { /// /// 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', + (ctor) => ctor.isFactory && !ctor.name3!.startsWith('_') && ctor.name3 != 'fromJson', ); if (factoryConstructor == null) { // No factory constructor, use the normal constructor - return fields; + return fields2; } - return factoryConstructor.parameters; + return factoryConstructor.formalParameters; } else { - final uniqueFields = {}; + 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.element3.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.name3!] ??= field; } return uniqueFields.values; } @@ -475,10 +454,9 @@ 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) && - element?.name == 'DocumentReference' && + return element3?.library2?.uri.scheme == 'package' && + const {'cloud_firestore'}.contains(element3?.library2?.uri.pathSegments.first) && + element3?.name3 == 'DocumentReference' && (this as InterfaceType).typeArguments.single.isDartCoreMap; } @@ -500,9 +478,9 @@ extension DartTypeExtension on DartType { } } -extension on Element { +extension on Element2 { bool isJsonIgnored() { - const checker = TypeChecker.fromRuntime(JsonKey); + const checker = TypeChecker.typeNamed(JsonKey); final jsonKeys = checker.annotationsOf(this); for (final jsonKey in jsonKeys) { @@ -511,7 +489,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; } @@ -521,7 +499,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..1d71f9e 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart @@ -2,7 +2,7 @@ // 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:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:build/build.dart'; import 'package:cloud_firestore_odm/annotation.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( @@ -66,21 +66,19 @@ class GlobalData { class CollectionGenerator extends ParserGenerator> { @override - GlobalData parseGlobalData(LibraryElement library) { + GlobalData parseGlobalData(LibraryElement2 library) { final globalData = GlobalData(); - for (final element in library.topLevelElements) { + for (final element in library.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( @@ -101,19 +99,18 @@ class CollectionGenerator Future parseElement( BuildStep buildStep, GlobalData globalData, - Element element, + Element2 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(); + print('element: ${element}'); + final collectionAnnotations = collectionChecker.annotationsOf(element).map((annotation) { + return CollectionData.fromAnnotation( + annotatedElement: element, + globalData: globalData, + libraryElement: library, + annotation: annotation, + ); + }).toList(); return CollectionGraph.parse(collectionAnnotations); } @@ -141,10 +138,9 @@ const _sentinel = _Sentinel(); } @override - Iterable generateForData( - GlobalData globalData, - CollectionGraph data, - ) sync* { + Iterable generateForData(GlobalData globalData, CollectionGraph data) sync* { + print('data: ${data.allCollections.map((e) => e.collectionReferenceInterfaceName)}'); + 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..da313a2 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart @@ -4,80 +4,49 @@ import 'dart:async'; -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:build/build.dart'; import 'package:source_gen/source_gen.dart'; -abstract class ParserGenerator +import 'collection_generator.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), - ); - + FutureOr generate(LibraryReader libraryReader, BuildStep buildStep) async { + final library = libraryReader.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); - } + 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(); + return '$generationBuffer\n\n${await super.generate(libraryReader, buildStep)}'; } Iterable generateForAll(GlobalData globalData) sync* {} - GlobalData parseGlobalData(LibraryElement library); + GlobalData parseGlobalData(LibraryElement2 library); - FutureOr parseElement( - BuildStep buildStep, - GlobalData globalData, - Element element, - ); + FutureOr parseElement(BuildStep buildStep, GlobalData globalData, Element2 element); Iterable generateForData(GlobalData globalData, Data data); @override Stream generateForAnnotatedElement( - Element element, + Element2 element, ConstantReader annotation, BuildStep buildStep, ) async* { // implemented for source_gen_test – otherwise unused - final globalData = parseGlobalData(element.library!); + final globalData = parseGlobalData(element.library2!); final data = parseElement(buildStep, globalData, element); if (data == null) return; 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 d9811c9..9477ed2 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart @@ -4,7 +4,7 @@ import 'dart:async'; -import 'package:analyzer/dart/element/element.dart'; +import 'package:analyzer/dart/element/element2.dart'; import 'package:build/build.dart'; import 'package:source_gen/source_gen.dart'; @@ -14,18 +14,18 @@ class ValidatorGenerator extends Generator { final buffer = StringBuffer(); for (final classElement in library.classes) { - final validations = classElement.fields.expand((field) sync* { - final validators = field.metadata.where(isValidatorAnnotation); + final validations = classElement.fields2.expand((field) sync* { + final validators = field.metadata2.annotations.where(isValidatorAnnotation); for (final validator in validators) { - yield "${validator.toSource().replaceFirst('@', 'const ')}.validate(instance.${field.name}, '${field.name}');"; + yield "${validator.toSource().replaceFirst('@', 'const ')}.validate(instance.${field.name3}, '${field.name3}');"; } }).toList(); if (validations.isNotEmpty) { buffer ..write( - 'void _\$assert${classElement.name}(${classElement.name} instance) {', + 'void _\$assert${classElement.name3}(${classElement.name3} instance) {', ) ..writeAll(validations) ..write('}'); @@ -37,12 +37,12 @@ class ValidatorGenerator extends Generator { } bool isValidatorAnnotation(ElementAnnotation annotation) { - final element = annotation.element; - if (element == null || element is! ConstructorElement) return false; + final element = annotation.element2; + if (element == null || element is! ConstructorElement2) return false; - return element.enclosingElement3.allSupertypes.any((superType) { - return superType.element.name == 'Validator' && - superType.element.librarySource.uri.toString() == + return element.enclosingElement2.allSupertypes.any((superType) { + return superType.element3.name3 == 'Validator' && + superType.element3.library2.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 caa7ec4..6b544c0 100644 --- a/packages/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/pubspec.yaml @@ -5,13 +5,15 @@ repository: https://github.com/firebaseextended/firestoreodm-flutter version: 1.2.0 environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" dependencies: - analyzer: ">=5.12.0 <8.0.0" - build: ^2.4.1 - build_config: ^1.1.2 - cloud_firestore_odm: ^1.2.0 + analyzer: ">=6.0.0 <9.0.0" + build: ^3.0.2 + build_config: ^1.2.0 + # cloud_firestore_odm: ^1.2.0 + cloud_firestore_odm: + path: ../cloud_firestore_odm collection: ^1.18.0 freezed_annotation: ^3.0.0 # Can be removed once this is fixed https://github.com/dart-lang/graphs/issues/86 @@ -19,12 +21,12 @@ dependencies: json_annotation: ^4.9.0 meta: ^1.12.0 recase: ^4.1.0 - source_gen: ^2.0.0 - source_helper: ^1.3.4 + source_gen: ^3.1.0 + source_helper: ^1.3.7 dev_dependencies: - build_runner: ^2.4.8 - expect_error: ^1.0.8 - json_serializable: ^6.9.4 - matcher: ^0.12.16 - test: ^1.25.1 + build_runner: ^2.7.0 + expect_error: ^1.0.10 + json_serializable: ^6.11.0 + matcher: ^0.12.17 + test: ^1.25.15 From fcd1361a4c74abdada0f989280a7a71754676c83 Mon Sep 17 00:00:00 2001 From: dorklein Date: Fri, 29 Aug 2025 16:09:06 +0700 Subject: [PATCH 4/8] chore: Bump version to 1.3.0 and upgrade dependencies for cloud_firestore_odm and generator - Updated version to 1.3.0 in pubspec.yaml files - Upgraded packages to support analyzer ^8 and set minimum SDK to 3.8.0 - Updated CHANGELOG to reflect changes --- packages/cloud_firestore_odm/CHANGELOG.md | 3 +++ packages/cloud_firestore_odm/pubspec.yaml | 2 +- packages/cloud_firestore_odm_generator/CHANGELOG.md | 3 +++ packages/cloud_firestore_odm_generator/pubspec.yaml | 9 +++++---- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/cloud_firestore_odm/CHANGELOG.md b/packages/cloud_firestore_odm/CHANGELOG.md index 8b10346..9fa6f9f 100644 --- a/packages/cloud_firestore_odm/CHANGELOG.md +++ b/packages/cloud_firestore_odm/CHANGELOG.md @@ -1,3 +1,6 @@ +## 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 diff --git a/packages/cloud_firestore_odm/pubspec.yaml b/packages/cloud_firestore_odm/pubspec.yaml index 9a8edd4..877eb88 100644 --- a/packages/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/pubspec.yaml @@ -2,7 +2,7 @@ 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.2.0 +version: 1.3.0 false_secrets: - example/** diff --git a/packages/cloud_firestore_odm_generator/CHANGELOG.md b/packages/cloud_firestore_odm_generator/CHANGELOG.md index ae0f17d..db5cbc8 100644 --- a/packages/cloud_firestore_odm_generator/CHANGELOG.md +++ b/packages/cloud_firestore_odm_generator/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.3.0 +- **CHORE**: upgraded packages to support analyzer ^8 and min sdk to 3.8.0 + ## 1.2.0 - **FIX**: `set`, `batchSet` and `transacrtionSet` methods would keep the `@ID() id` in the object in DB. - **CHORE**: Update cloud_firestore to ^6.0.0 diff --git a/packages/cloud_firestore_odm_generator/pubspec.yaml b/packages/cloud_firestore_odm_generator/pubspec.yaml index 6b544c0..7ff59fe 100644 --- a/packages/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/pubspec.yaml @@ -2,7 +2,7 @@ name: cloud_firestore_odm_generator description: A code generator for cloud_firestore_odm. homepage: https://firebase.flutter.dev/docs/firestore/odm repository: https://github.com/firebaseextended/firestoreodm-flutter -version: 1.2.0 +version: 1.3.0 environment: sdk: ">=3.8.0 <4.0.0" @@ -11,9 +11,10 @@ dependencies: analyzer: ">=6.0.0 <9.0.0" build: ^3.0.2 build_config: ^1.2.0 - # cloud_firestore_odm: ^1.2.0 - cloud_firestore_odm: - path: ../cloud_firestore_odm + cloud_firestore_odm: ^1.2.0 + # For testing locally + # cloud_firestore_odm: + # path: ../cloud_firestore_odm collection: ^1.18.0 freezed_annotation: ^3.0.0 # Can be removed once this is fixed https://github.com/dart-lang/graphs/issues/86 From 6f29f11dd6b0f8dbfb59482d9be5a8fa9aadb8cf Mon Sep 17 00:00:00 2001 From: Dor Klein Date: Fri, 29 Aug 2025 12:17:31 +0300 Subject: [PATCH 5/8] Update README.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c0cf42a..bbc6818 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ That is done by adding the following to your `pubspec.yaml`: ```yaml environment: - sdk: ">=3.0.0 <4.0.0" + sdk: ">=3.8.0 <4.0.0" ``` ### 2. FlutterFire Initialization From 389b61d77efbde5306d44cc243b2516776118666 Mon Sep 17 00:00:00 2001 From: dorklein Date: Fri, 29 Aug 2025 16:18:47 +0700 Subject: [PATCH 6/8] refactor: Simplify test assertions and remove debug print statements - Streamlined expect statements in integration tests for better readability. - Removed unnecessary print statements from collection data and generator files. - Enhanced code clarity by consolidating multi-line statements into single lines where appropriate. --- .../document_reference_test.dart | 108 +++++++----------- .../lib/src/collection_data.dart | 1 - .../lib/src/collection_generator.dart | 3 - 3 files changed, 40 insertions(+), 72 deletions(-) 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 093e409..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( @@ -138,11 +125,9 @@ void main() { expect( 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, - ), + isA() + .having((e) => e.data?.title, 'data.title', 'title') + .having((e) => e.metadata.isFromCache, 'metadata.isFromCache', true), ); }); }); @@ -156,8 +141,6 @@ void main() { (transaction) => collection.doc('123').transactionGet(transaction), ); - print('result.data ${result.data}'); - print('result.data ${result.data}'); expect(result.id, '123'); expect(result.data?.title, 'title'); }); @@ -188,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, @@ -245,10 +230,7 @@ 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( @@ -291,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, @@ -316,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), @@ -336,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, @@ -361,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, ); @@ -400,14 +386,8 @@ 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); }); }); @@ -417,37 +397,29 @@ void main() { 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'), 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 5df4ed8..8d77a65 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart @@ -96,7 +96,6 @@ class CollectionData with Names { required DartObject annotation, required GlobalData globalData, }) { - print('annotation: ${annotation}'); // TODO find a way to test validation final name = annotation.getField('name')!.toStringValue(); 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 1d71f9e..dedbfe2 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart @@ -102,7 +102,6 @@ class CollectionGenerator Element2 element, ) async { final library = await buildStep.inputLibrary; - print('element: ${element}'); final collectionAnnotations = collectionChecker.annotationsOf(element).map((annotation) { return CollectionData.fromAnnotation( annotatedElement: element, @@ -139,8 +138,6 @@ const _sentinel = _Sentinel(); @override Iterable generateForData(GlobalData globalData, CollectionGraph data) sync* { - print('data: ${data.allCollections.map((e) => e.collectionReferenceInterfaceName)}'); - for (final collection in data.allCollections) { yield CollectionReferenceTemplate(collection); yield DocumentReferenceTemplate(collection); From 46f0c380a5904e3cae77f0b36c9c198ce08b8503 Mon Sep 17 00:00:00 2001 From: Dor Klein Date: Fri, 29 Aug 2025 12:19:05 +0300 Subject: [PATCH 7/8] Update packages/cloud_firestore_odm_generator/CHANGELOG.md Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- packages/cloud_firestore_odm_generator/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloud_firestore_odm_generator/CHANGELOG.md b/packages/cloud_firestore_odm_generator/CHANGELOG.md index db5cbc8..58f2c8c 100644 --- a/packages/cloud_firestore_odm_generator/CHANGELOG.md +++ b/packages/cloud_firestore_odm_generator/CHANGELOG.md @@ -2,7 +2,7 @@ - **CHORE**: upgraded packages to support analyzer ^8 and min sdk to 3.8.0 ## 1.2.0 -- **FIX**: `set`, `batchSet` and `transacrtionSet` methods would keep the `@ID() id` in the object in DB. +- **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 From 6dabdaa9f5f906f89fcbf18cdd8a219ece5cafc0 Mon Sep 17 00:00:00 2001 From: dorklein Date: Wed, 24 Sep 2025 16:23:14 +0700 Subject: [PATCH 8/8] feat: Update code generation to use .firebase.dart files - Changed generated file postfix from .g.dart to .firebase.dart for better compatibility with Riverpod. - Updated documentation to reflect the new file naming convention. - Modified example files to include part declarations for .firebase.dart files. - Bumped version to 2.0.0 in pubspec.yaml and updated CHANGELOG to indicate breaking changes. --- docs/code-generation.md | 7 +- docs/defining-models.md | 1 + packages/cloud_firestore_odm/CHANGELOG.md | 3 + .../example/integration_test/common.dart | 8 +- .../example/lib/integration.dart | 4 +- .../example/lib/integration.firebase.dart | 3023 +++ .../example/lib/integration.g.dart | 3019 --- .../example/lib/integration/enums.dart | 7 +- .../lib/integration/enums.firebase.dart | 1848 ++ .../example/lib/integration/enums.g.dart | 1844 -- .../example/lib/integration/freezed.dart | 4 +- .../lib/integration/freezed.firebase.dart | 2138 ++ .../example/lib/integration/freezed.g.dart | 2134 -- .../example/lib/integration/named_query.dart | 1 + .../lib/integration/named_query.firebase.dart | 945 + .../lib/integration/named_query.g.dart | 941 - .../example/lib/integration/query.dart | 1 + .../lib/integration/query.firebase.dart | 4897 +++++ .../example/lib/integration/query.g.dart | 4893 ----- .../example/lib/movie.dart | 6 +- .../example/lib/movie.firebase.dart | 3616 ++++ .../example/lib/movie.g.dart | 3612 ---- .../cloud_firestore_odm/example/pubspec.yaml | 5 +- packages/cloud_firestore_odm/pubspec.yaml | 10 +- .../CHANGELOG.md | 3 + .../cloud_firestore_odm_generator/build.yaml | 8 +- .../build.yaml | 11 +- .../lib/freezed.dart | 1 + .../lib/freezed.firebase.dart | 3082 +++ .../lib/freezed.g.dart | 3078 --- .../lib/riverpod_integration.dart | 162 + .../lib/riverpod_integration.firebase.dart | 3411 ++++ .../lib/riverpod_integration.freezed.dart | 283 + .../lib/riverpod_integration.g.dart | 538 + .../lib/simple.dart | 1 + .../lib/simple.firebase.dart | 16148 ++++++++++++++++ .../lib/simple.g.dart | 16144 --------------- .../pubspec.yaml | 12 +- .../test/collection_test.dart | 30 +- .../test/riverpod_integration_test.dart | 155 + .../lib/cloud_firestore_odm_generator.dart | 9 +- .../lib/src/collection_data.dart | 70 +- .../lib/src/collection_generator.dart | 15 +- .../lib/src/parse_generator.dart | 31 +- .../lib/src/utils/errors.dart | 25 + .../lib/src/validator_generator.dart | 22 +- .../pubspec.yaml | 22 +- 47 files changed, 40416 insertions(+), 35812 deletions(-) create mode 100644 packages/cloud_firestore_odm/example/lib/integration.firebase.dart create mode 100644 packages/cloud_firestore_odm/example/lib/integration/enums.firebase.dart create mode 100644 packages/cloud_firestore_odm/example/lib/integration/freezed.firebase.dart create mode 100644 packages/cloud_firestore_odm/example/lib/integration/named_query.firebase.dart create mode 100644 packages/cloud_firestore_odm/example/lib/integration/query.firebase.dart create mode 100644 packages/cloud_firestore_odm/example/lib/movie.firebase.dart create mode 100644 packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.firebase.dart create mode 100644 packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.dart create mode 100644 packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.firebase.dart create mode 100644 packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.freezed.dart create mode 100644 packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/riverpod_integration.g.dart create mode 100644 packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/simple.firebase.dart create mode 100644 packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/test/riverpod_integration_test.dart create mode 100644 packages/cloud_firestore_odm_generator/lib/src/utils/errors.dart 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 9fa6f9f..c1ea7a0 100644 --- a/packages/cloud_firestore_odm/CHANGELOG.md +++ b/packages/cloud_firestore_odm/CHANGELOG.md @@ -1,3 +1,6 @@ +## 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 diff --git a/packages/cloud_firestore_odm/example/integration_test/common.dart b/packages/cloud_firestore_odm/example/integration_test/common.dart index be16607..1cb0846 100644 --- a/packages/cloud_firestore_odm/example/integration_test/common.dart +++ b/packages/cloud_firestore_odm/example/integration_test/common.dart @@ -9,14 +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/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 d2e9237..5f81aea 100644 --- a/packages/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/example/lib/integration.g.dart @@ -4,3025 +4,6 @@ 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); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** 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 8b303b5..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,1850 +4,6 @@ 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); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** diff --git a/packages/cloud_firestore_odm/example/lib/integration/freezed.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.dart index 483385a..6953668 100644 --- a/packages/cloud_firestore_odm/example/lib/integration/freezed.dart +++ b/packages/cloud_firestore_odm/example/lib/integration/freezed.dart @@ -8,6 +8,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 'freezed.firebase.dart'; part 'freezed.freezed.dart'; part 'freezed.g.dart'; @@ -31,6 +32,5 @@ final personRef = PersonCollectionReference(); 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.g.dart b/packages/cloud_firestore_odm/example/lib/integration/freezed.g.dart index 16371f8..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,2140 +4,6 @@ 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); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** 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 1a9d8c0..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,947 +4,6 @@ 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); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** 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 6fee6c7..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,4899 +4,6 @@ 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); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** 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 a1b19f3..bacce0a 100644 --- a/packages/cloud_firestore_odm/example/lib/movie.g.dart +++ b/packages/cloud_firestore_odm/example/lib/movie.g.dart @@ -4,3618 +4,6 @@ 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'); -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** diff --git a/packages/cloud_firestore_odm/example/pubspec.yaml b/packages/cloud_firestore_odm/example/pubspec.yaml index 729164d..3ffb645 100644 --- a/packages/cloud_firestore_odm/example/pubspec.yaml +++ b/packages/cloud_firestore_odm/example/pubspec.yaml @@ -6,7 +6,7 @@ environment: dependencies: cloud_firestore: ^6.0.0 - cloud_firestore_odm: ^1.2.0 + cloud_firestore_odm: ^2.0.0 firebase_core: ^4.0.0 flutter: sdk: flutter @@ -15,7 +15,7 @@ dependencies: meta: ^1.12.0 dev_dependencies: - build_runner: ^2.7.0 + build_runner: ^2.8.0 cloud_firestore_odm_generator: path: ../../cloud_firestore_odm_generator cloud_firestore_odm_generator_integration_test: @@ -32,6 +32,7 @@ dev_dependencies: dependency_overrides: cloud_firestore_odm: path: ../ + test_api: ^0.7.7 flutter: uses-material-design: true diff --git a/packages/cloud_firestore_odm/pubspec.yaml b/packages/cloud_firestore_odm/pubspec.yaml index 877eb88..2fa60f2 100644 --- a/packages/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/pubspec.yaml @@ -2,13 +2,13 @@ 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.3.0 +version: 2.0.0 false_secrets: - example/** environment: - sdk: ">=3.8.0 <4.0.0" + sdk: ">=3.9.2 <4.0.0" dependencies: cloud_firestore: ^6.0.0 @@ -20,4 +20,8 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - test: ^1.25.15 + 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 58f2c8c..cf94899 100644 --- a/packages/cloud_firestore_odm_generator/CHANGELOG.md +++ b/packages/cloud_firestore_odm_generator/CHANGELOG.md @@ -1,3 +1,6 @@ +## 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 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 e243b7f..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,6 +8,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 'freezed.firebase.dart'; part 'freezed.freezed.dart'; part 'freezed.g.dart'; 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.g.dart b/packages/cloud_firestore_odm_generator/cloud_firestore_odm_generator_integration_test/lib/freezed.g.dart index a3f0e99..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 @@ -2,3084 +2,6 @@ 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); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** 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 3ff9923..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(); 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 f70e1fc..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,16150 +2,6 @@ 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'); -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** 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 4db0592..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,19 +2,21 @@ name: cloud_firestore_odm_generator_integration_test publish_to: none environment: - sdk: ">=3.8.0 <4.0.0" + sdk: ">=3.9.2 <4.0.0" dependencies: cloud_firestore: ^6.0.0 - cloud_firestore_odm: ^1.2.0 + cloud_firestore_odm: ^2.0.0 flutter: sdk: flutter + 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.7.0 + build_runner: ^2.8.0 cloud_firestore_odm_generator: path: ../ firebase_core_platform_interface: ^6.0.0 @@ -22,11 +24,13 @@ dev_dependencies: sdk: flutter freezed: ^3.2.0 json_serializable: ^6.11.0 - test: ^1.25.15 + 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 62a7da8..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 @@ -12,26 +12,14 @@ void main() { 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()); }); }); @@ -39,14 +27,8 @@ void main() { 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); }); }); 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/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 8d77a65..55b7616 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_data.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:analyzer/dart/constant/value.dart'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:cloud_firestore_odm/annotation.dart'; import 'package:collection/collection.dart'; @@ -91,8 +91,8 @@ class CollectionData with Names { }) : collectionName = collectionName ?? ReCase(path.split('/').last).camelCase; factory CollectionData.fromAnnotation({ - required LibraryElement2 libraryElement, - required Element2 annotatedElement, + required LibraryElement libraryElement, + required Element annotatedElement, required DartObject annotation, required GlobalData globalData, }) { @@ -117,8 +117,8 @@ class CollectionData with Names { ); } - final collectionTargetElement = type.element3; - if (collectionTargetElement is! ClassElement2) { + final collectionTargetElement = type.element; + if (collectionTargetElement is! ClassElement) { throw InvalidGenerationSourceError( 'The annotation @Collection can only receive classes as generic argument. ', element: annotatedElement, @@ -137,25 +137,25 @@ class CollectionData with Names { // Freezed classes are also JsonSerializable if (!hasJsonSerializable && !hasFreezed) { throw InvalidGenerationSourceError( - 'Used @Collection with the class ${collectionTargetElement.name3}, but ' + 'Used @Collection with the class ${collectionTargetElement.name}, but ' 'the class has no @JsonSerializable annotation.', ); } - final annotatedElementSource = annotatedElement.library2; + 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.library2 == annotatedElementSource; + collectionTargetElement.library == annotatedElementSource; if (!modelAndReferenceInTheSameLibrary) { 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.library2} +- `$collectionTargetElement` is from ${collectionTargetElement.library} ''', element: annotatedElement); } @@ -167,9 +167,9 @@ represents the content of the collection must be in the same file. ); } - final collectionTargetElementPublicType = collectionTargetElement.name3?.public ?? ''; + final collectionTargetElementPublicType = collectionTargetElement.name?.public ?? ''; final fromJson = collectionTargetElement.constructors2.firstWhereOrNull( - (ctor) => ctor.name3 == 'fromJson', + (ctor) => ctor.name == 'fromJson', ); if (fromJson != null) { if (fromJson.formalParameters.length != 1 || @@ -177,7 +177,7 @@ represents the content of the collection must be in the same file. !fromJson.formalParameters.last.type.isDartCoreMap) { // TODO support deserializing generic objects throw InvalidGenerationSourceError( - '@Collection was used with the class ${collectionTargetElement.name3} but ' + '@Collection was used with the class ${collectionTargetElement.name} but ' 'its fromJson does not match `Function(Map json)`.', element: annotatedElement, ); @@ -186,9 +186,9 @@ represents the content of the collection must be in the same file. final toJson = collectionTargetElement // Looking into fromJson from superTypes too .allMethods - .firstWhereOrNull((method) => method.name3 == 'toJson'); + .firstWhereOrNull((method) => method.name == 'toJson'); final redirectedFreezedClass = - redirectedFreezedConstructors.singleOrNull?.redirectedConstructor2!.enclosingElement2.name3; + redirectedFreezedConstructors.singleOrNull?.redirectedConstructor2!.enclosingElement.name; final generatedJsonTypePrefix = _generatedJsonTypePrefix( hasFreezed: hasFreezed, redirectedFreezedClass: redirectedFreezedClass, @@ -198,7 +198,7 @@ represents the content of the collection must be in the same file. if (toJson.formalParameters.isNotEmpty || !toJson.returnType.isDartCoreMap) { // TODO support serializing generic objects throw InvalidGenerationSourceError( - '@Collection was used with the class ${collectionTargetElement.name3} but ' + '@Collection was used with the class ${collectionTargetElement.name} but ' 'its toJson does not match `Map Function()`.', element: annotatedElement, ); @@ -222,7 +222,7 @@ represents the content of the collection must be in the same file. idKey: collectionTargetElement .allFields(hasFreezed: hasFreezed, freezedConstructors: redirectedFreezedConstructors) .firstWhereOrNull((f) => f.hasId()) - ?.name3, + ?.name, queryableFields: [ QueryingField( 'fieldPath', @@ -265,13 +265,13 @@ represents the content of the collection must be in the same file. /// ```dart /// collection.orderByTitle(startAt: 'title'); /// ```''', - annotatedElement.library2!.typeProvider.objectType, + annotatedElement.library!.typeProvider.objectType, field: 'fieldPath', updatable: false, ), QueryingField( 'documentId', - annotatedElement.library2!.typeProvider.stringType, + annotatedElement.library!.typeProvider.stringType, whereDoc: '', // Inherited orderByDoc: '', // Inherited field: 'FieldPath.documentId', @@ -284,12 +284,12 @@ represents the content of the collection must be in the same file. .where((f) => !f.isJsonIgnored()) .map( (f) => QueryingField( - f.name3!, + f.name!, f.type, whereDoc: '', orderByDoc: '', updatable: true, - field: "${generatedJsonTypePrefix}FieldMap['${f.name3}']!", + field: "${generatedJsonTypePrefix}FieldMap['${f.name}']!", ), ) .toList(), @@ -312,7 +312,7 @@ represents the content of the collection must be in the same file. return data; } - static void _assertIsValidCollectionPath(String? path, Element2 element) { + static void _assertIsValidCollectionPath(String? path, Element element) { if (path == null) { throw InvalidGenerationSourceError( 'The annotation @Collection received "$path" as collection path, ' @@ -377,7 +377,7 @@ represents the content of the collection must be in the same file. final String path; final String? idKey; final List queryableFields; - final LibraryElement2 libraryElement; + final LibraryElement libraryElement; late final updatableFields = queryableFields.where((element) => element.updatable).toList(); @@ -397,8 +397,8 @@ represents the content of the collection must be in the same file. } } -extension on ClassElement2 { - Iterable get allMethods sync* { +extension on ClassElement { + Iterable get allMethods sync* { yield* methods2; for (final supertype in allSupertypes) { if (supertype.isDartCoreObject) continue; @@ -406,9 +406,9 @@ extension on ClassElement2 { } } - Iterable allFields({ + Iterable allFields({ required bool hasFreezed, - required List freezedConstructors, + required List freezedConstructors, }) { if (hasFreezed) { /// For Freezed 3.x, support mixed mode classes. There can be the classic freezed way with a factory, @@ -416,7 +416,7 @@ extension on ClassElement2 { /// /// We need to find the factory constructor, or the normal constructor if there is no factory. final factoryConstructor = freezedConstructors.firstWhereOrNull( - (ctor) => ctor.isFactory && !ctor.name3!.startsWith('_') && ctor.name3 != 'fromJson', + (ctor) => ctor.isFactory && !ctor.name!.startsWith('_') && ctor.name != 'fromJson', ); if (factoryConstructor == null) { // No factory constructor, use the normal constructor @@ -424,18 +424,18 @@ extension on ClassElement2 { } return factoryConstructor.formalParameters; } else { - final uniqueFields = {}; + final uniqueFields = {}; - final allFields = const [] + final allFields = const [] .followedBy(fields2) .followedBy( - allSupertypes.where((e) => !e.isDartCoreObject).expand((e) => e.element3.fields2), + allSupertypes.where((e) => !e.isDartCoreObject).expand((e) => e.element.fields2), ); for (final field in allFields) { if (field.getter2 != null && !field.getter2!.isSynthetic) continue; if (field.isStatic) continue; - uniqueFields[field.name3!] ??= field; + uniqueFields[field.name!] ??= field; } return uniqueFields.values; } @@ -453,9 +453,9 @@ const _coreSetChecker = TypeChecker.fromUrl('dart:core#Set'); extension DartTypeExtension on DartType { bool get isJsonDocumentReference { - return element3?.library2?.uri.scheme == 'package' && - const {'cloud_firestore'}.contains(element3?.library2?.uri.pathSegments.first) && - element3?.name3 == 'DocumentReference' && + return element?.library?.uri.scheme == 'package' && + const {'cloud_firestore'}.contains(element?.library?.uri.pathSegments.first) && + element?.name == 'DocumentReference' && (this as InterfaceType).typeArguments.single.isDartCoreMap; } @@ -477,7 +477,7 @@ extension DartTypeExtension on DartType { } } -extension on Element2 { +extension on Element { bool isJsonIgnored() { const checker = TypeChecker.typeNamed(JsonKey); final jsonKeys = checker.annotationsOf(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 dedbfe2..4eb8ea7 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/collection_generator.dart @@ -2,7 +2,7 @@ // 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:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:build/build.dart'; import 'package:cloud_firestore_odm/annotation.dart'; @@ -63,13 +63,12 @@ class GlobalData { } @immutable -class CollectionGenerator - extends ParserGenerator> { +class CollectionGenerator extends ParserGenerator> { @override - GlobalData parseGlobalData(LibraryElement2 library) { + GlobalData parseGlobalData(LibraryElement element) { final globalData = GlobalData(); - for (final element in library.topLevelVariables) { + for (final element in element.topLevelVariables) { for (final queryAnnotation in namedQueryChecker.annotationsOf(element)) { final queryData = NamedQueryData.fromAnnotation(queryAnnotation); @@ -99,14 +98,14 @@ class CollectionGenerator Future parseElement( BuildStep buildStep, GlobalData globalData, - Element2 element, + Element element, ) async { - final library = await buildStep.inputLibrary; + final libraryElement = await buildStep.inputLibrary; final collectionAnnotations = collectionChecker.annotationsOf(element).map((annotation) { return CollectionData.fromAnnotation( annotatedElement: element, globalData: globalData, - libraryElement: library, + libraryElement: libraryElement, annotation: annotation, ); }).toList(); 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 da313a2..2d4f944 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/parse_generator.dart @@ -4,23 +4,23 @@ import 'dart:async'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:build/build.dart'; import 'package:source_gen/source_gen.dart'; +import 'collection_data.dart'; import 'collection_generator.dart'; -abstract class ParserGenerator - extends GeneratorForAnnotation { +abstract class ParserGenerator extends GeneratorForAnnotation { @override - FutureOr generate(LibraryReader libraryReader, BuildStep buildStep) async { - final library = libraryReader.element; + 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); + final globalData = parseGlobalData(element); for (final generated in generateForAll(globalData).map((e) => e.toString())) { assert(generated.length == generated.trim().length); if (generatedCache.add(generated)) { @@ -28,30 +28,29 @@ abstract class ParserGenerator } } - return '$generationBuffer\n\n${await super.generate(libraryReader, buildStep)}'; + final superGenerated = await super.generate(library, buildStep); + return '$generationBuffer\n\n$superGenerated'; } Iterable generateForAll(GlobalData globalData) sync* {} - GlobalData parseGlobalData(LibraryElement2 library); + GlobalData parseGlobalData(LibraryElement library); - FutureOr parseElement(BuildStep buildStep, GlobalData globalData, Element2 element); + Future parseElement(BuildStep buildStep, GlobalData globalData, Element element); - Iterable generateForData(GlobalData globalData, Data data); + Iterable generateForData(GlobalData globalData, CollectionGraph data); @override Stream generateForAnnotatedElement( - Element2 element, + Element element, ConstantReader annotation, BuildStep buildStep, ) async* { // implemented for source_gen_test – otherwise unused - final globalData = parseGlobalData(element.library2!); - final data = parseElement(buildStep, globalData, element); + final globalData = parseGlobalData(element.library!); + final data = await parseElement(buildStep, globalData, element); - if (data == null) return; - - 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/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 9477ed2..c3f83d0 100644 --- a/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart +++ b/packages/cloud_firestore_odm_generator/lib/src/validator_generator.dart @@ -4,7 +4,7 @@ import 'dart:async'; -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:build/build.dart'; import 'package:source_gen/source_gen.dart'; @@ -14,19 +14,17 @@ class ValidatorGenerator extends Generator { final buffer = StringBuffer(); for (final classElement in library.classes) { - final validations = classElement.fields2.expand((field) sync* { - final validators = field.metadata2.annotations.where(isValidatorAnnotation); + final validations = classElement.fields.expand((field) sync* { + final validators = field.metadata.annotations.where(isValidatorAnnotation); for (final validator in validators) { - yield "${validator.toSource().replaceFirst('@', 'const ')}.validate(instance.${field.name3}, '${field.name3}');"; + yield "${validator.toSource().replaceFirst('@', 'const ')}.validate(instance.${field.name}, '${field.name}');"; } }).toList(); if (validations.isNotEmpty) { buffer - ..write( - 'void _\$assert${classElement.name3}(${classElement.name3} instance) {', - ) + ..write('void _\$assert${classElement.name}(${classElement.name} instance) {') ..writeAll(validations) ..write('}'); } @@ -37,12 +35,12 @@ class ValidatorGenerator extends Generator { } bool isValidatorAnnotation(ElementAnnotation annotation) { - final element = annotation.element2; - if (element == null || element is! ConstructorElement2) return false; + final element = annotation.element; + if (element == null || element is! ConstructorElement) return false; - return element.enclosingElement2.allSupertypes.any((superType) { - return superType.element3.name3 == 'Validator' && - superType.element3.library2.uri.toString() == + return element.enclosingElement.allSupertypes.any((superType) { + return superType.element.name == 'Validator' && + 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 7ff59fe..440cf1c 100644 --- a/packages/cloud_firestore_odm_generator/pubspec.yaml +++ b/packages/cloud_firestore_odm_generator/pubspec.yaml @@ -2,32 +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.3.0 +version: 2.0.0 environment: - sdk: ">=3.8.0 <4.0.0" + sdk: ">=3.9.2 <4.0.0" dependencies: - analyzer: ">=6.0.0 <9.0.0" - build: ^3.0.2 - build_config: ^1.2.0 - cloud_firestore_odm: ^1.2.0 + 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 - # Can be removed once this is fixed https://github.com/dart-lang/graphs/issues/86 - graphs: ^2.3.1 json_annotation: ^4.9.0 meta: ^1.12.0 recase: ^4.1.0 - source_gen: ^3.1.0 + source_gen: ^4.0.1 source_helper: ^1.3.7 dev_dependencies: - build_runner: ^2.7.0 + build_runner: ^2.8.0 expect_error: ^1.0.10 json_serializable: ^6.11.0 matcher: ^0.12.17 - test: ^1.25.15 + test: ^1.26.3 + +dependency_overrides: + test_api: ^0.7.7