diff --git a/lib/features/post/model/post.dart b/lib/features/post/model/post.dart index 4d7ecd03..664a2844 100644 --- a/lib/features/post/model/post.dart +++ b/lib/features/post/model/post.dart @@ -1,5 +1,4 @@ import 'package:cloud_firestore/cloud_firestore.dart'; -import 'package:cloud_firestore_odm/annotation.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:json_converter_helper/json_converter_helper.dart'; import 'package:nippo/core/const.dart'; @@ -30,9 +29,6 @@ class Post with _$Post { late final String postId = nullablePostId!; } -@Collection(CollectionName.posts) -final postsRef = PostCollectionReference(); - extension PostDocumentReferenceX on DocumentReference { String? get uid => parent.parent?.id; } diff --git a/lib/features/post/model/post.g.dart b/lib/features/post/model/post.g.dart index 66056bb9..ef1c95e0 100644 --- a/lib/features/post/model/post.g.dart +++ b/lib/features/post/model/post.g.dart @@ -4,1452 +4,6 @@ part of 'post.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 - -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 PostCollectionReference - implements - PostQuery, - FirestoreCollectionReference { - factory PostCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$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; - - @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([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$PostCollectionReference._( - firestore.collection('posts').withConverter( - fromFirestore: PostCollectionReference.fromFirestore, - toFirestore: PostCollectionReference.toFirestore, - ), - ); - } - - _$PostCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - 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.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// 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? nullablePostId, - FieldValue nullablePostIdFieldValue, - String title, - FieldValue titleFieldValue, - String description, - FieldValue descriptionFieldValue, - UnionTimestamp updatedAt, - FieldValue updatedAtFieldValue, - UnionTimestamp 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? nullablePostId, - FieldValue nullablePostIdFieldValue, - String title, - FieldValue titleFieldValue, - String description, - FieldValue descriptionFieldValue, - UnionTimestamp updatedAt, - FieldValue updatedAtFieldValue, - UnionTimestamp 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.firestore); - } - - @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 update({ - Object? nullablePostId = _sentinel, - FieldValue? nullablePostIdFieldValue, - Object? title = _sentinel, - FieldValue? titleFieldValue, - Object? description = _sentinel, - FieldValue? descriptionFieldValue, - Object? updatedAt = _sentinel, - FieldValue? updatedAtFieldValue, - Object? createdAt = _sentinel, - FieldValue? createdAtFieldValue, - }) async { - assert( - nullablePostId == _sentinel || nullablePostIdFieldValue == null, - "Cannot specify both nullablePostId and nullablePostIdFieldValue", - ); - assert( - title == _sentinel || titleFieldValue == null, - "Cannot specify both title and titleFieldValue", - ); - assert( - description == _sentinel || descriptionFieldValue == null, - "Cannot specify both description and descriptionFieldValue", - ); - assert( - updatedAt == _sentinel || updatedAtFieldValue == null, - "Cannot specify both updatedAt and updatedAtFieldValue", - ); - assert( - createdAt == _sentinel || createdAtFieldValue == null, - "Cannot specify both createdAt and createdAtFieldValue", - ); - final json = { - if (nullablePostId != _sentinel) - _$$PostImplFieldMap['nullablePostId']!: - _$$PostImplPerFieldToJson.nullablePostId(nullablePostId as String?), - if (nullablePostIdFieldValue != null) - _$$PostImplFieldMap['nullablePostId']!: nullablePostIdFieldValue, - if (title != _sentinel) - _$$PostImplFieldMap['title']!: - _$$PostImplPerFieldToJson.title(title as String), - if (titleFieldValue != null) - _$$PostImplFieldMap['title']!: titleFieldValue, - if (description != _sentinel) - _$$PostImplFieldMap['description']!: - _$$PostImplPerFieldToJson.description(description as String), - if (descriptionFieldValue != null) - _$$PostImplFieldMap['description']!: descriptionFieldValue, - if (updatedAt != _sentinel) - _$$PostImplFieldMap['updatedAt']!: - _$$PostImplPerFieldToJson.updatedAt(updatedAt as UnionTimestamp), - if (updatedAtFieldValue != null) - _$$PostImplFieldMap['updatedAt']!: updatedAtFieldValue, - if (createdAt != _sentinel) - _$$PostImplFieldMap['createdAt']!: - _$$PostImplPerFieldToJson.createdAt(createdAt as UnionTimestamp), - if (createdAtFieldValue != null) - _$$PostImplFieldMap['createdAt']!: createdAtFieldValue, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - Object? nullablePostId = _sentinel, - FieldValue? nullablePostIdFieldValue, - Object? title = _sentinel, - FieldValue? titleFieldValue, - Object? description = _sentinel, - FieldValue? descriptionFieldValue, - Object? updatedAt = _sentinel, - FieldValue? updatedAtFieldValue, - Object? createdAt = _sentinel, - FieldValue? createdAtFieldValue, - }) { - assert( - nullablePostId == _sentinel || nullablePostIdFieldValue == null, - "Cannot specify both nullablePostId and nullablePostIdFieldValue", - ); - assert( - title == _sentinel || titleFieldValue == null, - "Cannot specify both title and titleFieldValue", - ); - assert( - description == _sentinel || descriptionFieldValue == null, - "Cannot specify both description and descriptionFieldValue", - ); - assert( - updatedAt == _sentinel || updatedAtFieldValue == null, - "Cannot specify both updatedAt and updatedAtFieldValue", - ); - assert( - createdAt == _sentinel || createdAtFieldValue == null, - "Cannot specify both createdAt and createdAtFieldValue", - ); - final json = { - if (nullablePostId != _sentinel) - _$$PostImplFieldMap['nullablePostId']!: - _$$PostImplPerFieldToJson.nullablePostId(nullablePostId as String?), - if (nullablePostIdFieldValue != null) - _$$PostImplFieldMap['nullablePostId']!: nullablePostIdFieldValue, - if (title != _sentinel) - _$$PostImplFieldMap['title']!: - _$$PostImplPerFieldToJson.title(title as String), - if (titleFieldValue != null) - _$$PostImplFieldMap['title']!: titleFieldValue, - if (description != _sentinel) - _$$PostImplFieldMap['description']!: - _$$PostImplPerFieldToJson.description(description as String), - if (descriptionFieldValue != null) - _$$PostImplFieldMap['description']!: descriptionFieldValue, - if (updatedAt != _sentinel) - _$$PostImplFieldMap['updatedAt']!: - _$$PostImplPerFieldToJson.updatedAt(updatedAt as UnionTimestamp), - if (updatedAtFieldValue != null) - _$$PostImplFieldMap['updatedAt']!: updatedAtFieldValue, - if (createdAt != _sentinel) - _$$PostImplFieldMap['createdAt']!: - _$$PostImplPerFieldToJson.createdAt(createdAt as UnionTimestamp), - if (createdAtFieldValue != null) - _$$PostImplFieldMap['createdAt']!: createdAtFieldValue, - }; - - transaction.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 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( - FieldPath fieldPath, { - bool descending = false, - Object? startAt, - Object? startAfter, - Object? endAt, - Object? endBefore, - PostDocumentSnapshot? startAtDocument, - PostDocumentSnapshot? endAtDocument, - PostDocumentSnapshot? endBeforeDocument, - PostDocumentSnapshot? startAfterDocument, - }); - - /// 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( - FieldPath 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, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - PostQuery whereNullablePostId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - PostQuery whereTitle({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - PostQuery whereDescription({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - PostQuery whereUpdatedAt({ - UnionTimestamp? isEqualTo, - UnionTimestamp? isNotEqualTo, - UnionTimestamp? isLessThan, - UnionTimestamp? isLessThanOrEqualTo, - UnionTimestamp? isGreaterThan, - UnionTimestamp? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - PostQuery whereCreatedAt({ - UnionTimestamp? isEqualTo, - UnionTimestamp? isNotEqualTo, - UnionTimestamp? isLessThan, - UnionTimestamp? isLessThanOrEqualTo, - UnionTimestamp? isGreaterThan, - UnionTimestamp? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - - PostQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PostDocumentSnapshot? startAtDocument, - PostDocumentSnapshot? endAtDocument, - PostDocumentSnapshot? endBeforeDocument, - PostDocumentSnapshot? startAfterDocument, - }); - - PostQuery orderByNullablePostId({ - 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 orderByDescription({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - PostDocumentSnapshot? startAtDocument, - PostDocumentSnapshot? endAtDocument, - PostDocumentSnapshot? endBeforeDocument, - PostDocumentSnapshot? startAfterDocument, - }); - - PostQuery orderByUpdatedAt({ - bool descending = false, - UnionTimestamp startAt, - UnionTimestamp startAfter, - UnionTimestamp endAt, - UnionTimestamp endBefore, - PostDocumentSnapshot? startAtDocument, - PostDocumentSnapshot? endAtDocument, - PostDocumentSnapshot? endBeforeDocument, - PostDocumentSnapshot? startAfterDocument, - }); - - PostQuery orderByCreatedAt({ - bool descending = false, - UnionTimestamp startAt, - UnionTimestamp startAfter, - UnionTimestamp endAt, - UnionTimestamp 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, - ); - } - - PostQuery orderByFieldPath( - FieldPath 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, - ); - } - - PostQuery whereFieldPath( - FieldPath fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - 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, - isNotEqualTo: isNotEqualTo, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull, - ), - $queryCursor: $queryCursor, - ); - } - - PostQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$PostQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo, - isNotEqualTo: isNotEqualTo, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - isNull: isNull, - whereIn: whereIn, - whereNotIn: whereNotIn, - ), - $queryCursor: $queryCursor, - ); - } - - PostQuery whereNullablePostId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$PostQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PostImplFieldMap['nullablePostId']!, - isEqualTo: isEqualTo != null - ? _$$PostImplPerFieldToJson.nullablePostId(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$PostImplPerFieldToJson.nullablePostId(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$PostImplPerFieldToJson.nullablePostId(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.nullablePostId(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PostImplPerFieldToJson.nullablePostId(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.nullablePostId(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: - whereIn?.map((e) => _$$PostImplPerFieldToJson.nullablePostId(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PostImplPerFieldToJson.nullablePostId(e)), - ), - $queryCursor: $queryCursor, - ); - } - - PostQuery whereTitle({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$PostQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PostImplFieldMap['title']!, - isEqualTo: isEqualTo != null - ? _$$PostImplPerFieldToJson.title(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$PostImplPerFieldToJson.title(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$PostImplPerFieldToJson.title(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.title(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PostImplPerFieldToJson.title(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.title(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$PostImplPerFieldToJson.title(e)), - whereNotIn: whereNotIn?.map((e) => _$$PostImplPerFieldToJson.title(e)), - ), - $queryCursor: $queryCursor, - ); - } - - PostQuery whereDescription({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$PostQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PostImplFieldMap['description']!, - isEqualTo: isEqualTo != null - ? _$$PostImplPerFieldToJson.description(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$PostImplPerFieldToJson.description(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$PostImplPerFieldToJson.description(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.description(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PostImplPerFieldToJson.description(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.description(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$PostImplPerFieldToJson.description(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PostImplPerFieldToJson.description(e)), - ), - $queryCursor: $queryCursor, - ); - } - - PostQuery whereUpdatedAt({ - UnionTimestamp? isEqualTo, - UnionTimestamp? isNotEqualTo, - UnionTimestamp? isLessThan, - UnionTimestamp? isLessThanOrEqualTo, - UnionTimestamp? isGreaterThan, - UnionTimestamp? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$PostQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PostImplFieldMap['updatedAt']!, - isEqualTo: isEqualTo != null - ? _$$PostImplPerFieldToJson.updatedAt(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$PostImplPerFieldToJson.updatedAt(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$PostImplPerFieldToJson.updatedAt(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.updatedAt(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PostImplPerFieldToJson.updatedAt(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.updatedAt(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$PostImplPerFieldToJson.updatedAt(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PostImplPerFieldToJson.updatedAt(e)), - ), - $queryCursor: $queryCursor, - ); - } - - PostQuery whereCreatedAt({ - UnionTimestamp? isEqualTo, - UnionTimestamp? isNotEqualTo, - UnionTimestamp? isLessThan, - UnionTimestamp? isLessThanOrEqualTo, - UnionTimestamp? isGreaterThan, - UnionTimestamp? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$PostQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$PostImplFieldMap['createdAt']!, - isEqualTo: isEqualTo != null - ? _$$PostImplPerFieldToJson.createdAt(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$PostImplPerFieldToJson.createdAt(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$PostImplPerFieldToJson.createdAt(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.createdAt(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$PostImplPerFieldToJson.createdAt(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$PostImplPerFieldToJson.createdAt(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$PostImplPerFieldToJson.createdAt(e)), - whereNotIn: - whereNotIn?.map((e) => _$$PostImplPerFieldToJson.createdAt(e)), - ), - $queryCursor: $queryCursor, - ); - } - - 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, - ); - } - - PostQuery orderByNullablePostId({ - 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( - _$$PostImplFieldMap['nullablePostId']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (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, - ); - } - - 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(_$$PostImplFieldMap['title']!, - descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$PostQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - PostQuery orderByDescription({ - 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(_$$PostImplFieldMap['description']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (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, - ); - } - - PostQuery orderByUpdatedAt({ - 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(_$$PostImplFieldMap['updatedAt']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (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, - ); - } - - 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(_$$PostImplFieldMap['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, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (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 - 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); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** diff --git a/lib/features/user/model/user.dart b/lib/features/user/model/user.dart index f40fc625..04476aa5 100644 --- a/lib/features/user/model/user.dart +++ b/lib/features/user/model/user.dart @@ -1,7 +1,5 @@ -import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:json_converter_helper/json_converter_helper.dart'; -import 'package:nippo/core/const.dart'; part 'user.freezed.dart'; part 'user.g.dart'; @@ -19,6 +17,3 @@ class User with _$User { factory User.fromJson(Map json) => _$UserFromJson(json); } - -@Collection(CollectionName.users) -final usersRef = UserCollectionReference(); diff --git a/lib/features/user/model/user.g.dart b/lib/features/user/model/user.g.dart index 8ea5c7c1..7017be67 100644 --- a/lib/features/user/model/user.g.dart +++ b/lib/features/user/model/user.g.dart @@ -4,1447 +4,6 @@ part of 'user.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 - -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 UserCollectionReference - implements - UserQuery, - FirestoreCollectionReference { - factory UserCollectionReference([ - FirebaseFirestore? firestore, - ]) = _$UserCollectionReference; - - static User fromFirestore( - DocumentSnapshot> snapshot, - SnapshotOptions? options, - ) { - return User.fromJson(snapshot.data()!); - } - - static Map toFirestore( - User value, - SetOptions? options, - ) { - return value.toJson(); - } - - @override - CollectionReference get reference; - - @override - UserDocumentReference doc([String? id]); - - /// Add a new document to this collection with the specified data, - /// assigning it a document ID automatically. - Future add(User value); -} - -class _$UserCollectionReference extends _$UserQuery - implements UserCollectionReference { - factory _$UserCollectionReference([FirebaseFirestore? firestore]) { - firestore ??= FirebaseFirestore.instance; - - return _$UserCollectionReference._( - firestore.collection('users').withConverter( - fromFirestore: UserCollectionReference.fromFirestore, - toFirestore: UserCollectionReference.toFirestore, - ), - ); - } - - _$UserCollectionReference._( - CollectionReference reference, - ) : super(reference, $referenceWithoutCursor: reference); - - String get path => reference.path; - - @override - CollectionReference get reference => - super.reference as CollectionReference; - - @override - UserDocumentReference doc([String? id]) { - assert( - id == null || id.split('/').length == 1, - 'The document ID cannot be from a different collection', - ); - return UserDocumentReference( - reference.doc(id), - ); - } - - @override - Future add(User value) { - return reference.add(value).then((ref) => UserDocumentReference(ref)); - } - - @override - bool operator ==(Object other) { - return other is _$UserCollectionReference && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -abstract class UserDocumentReference - extends FirestoreDocumentReference { - factory UserDocumentReference(DocumentReference reference) = - _$UserDocumentReference; - - DocumentReference get reference; - - /// A reference to the [UserCollectionReference] containing this document. - UserCollectionReference get parent { - return _$UserCollectionReference(reference.firestore); - } - - @override - Stream snapshots(); - - @override - Future get([GetOptions? options]); - - @override - Future delete(); - - /// 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 name, - FieldValue nameFieldValue, - String email, - FieldValue emailFieldValue, - String? photoUrl, - FieldValue photoUrlFieldValue, - UnionTimestamp updatedAt, - FieldValue updatedAtFieldValue, - UnionTimestamp 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 name, - FieldValue nameFieldValue, - String email, - FieldValue emailFieldValue, - String? photoUrl, - FieldValue photoUrlFieldValue, - UnionTimestamp updatedAt, - FieldValue updatedAtFieldValue, - UnionTimestamp createdAt, - FieldValue createdAtFieldValue, - }); -} - -class _$UserDocumentReference - extends FirestoreDocumentReference - implements UserDocumentReference { - _$UserDocumentReference(this.reference); - - @override - final DocumentReference reference; - - /// A reference to the [UserCollectionReference] containing this document. - UserCollectionReference get parent { - return _$UserCollectionReference(reference.firestore); - } - - @override - Stream snapshots() { - return reference.snapshots().map(UserDocumentSnapshot._); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(UserDocumentSnapshot._); - } - - @override - Future transactionGet(Transaction transaction) { - return transaction.get(reference).then(UserDocumentSnapshot._); - } - - Future update({ - Object? name = _sentinel, - FieldValue? nameFieldValue, - Object? email = _sentinel, - FieldValue? emailFieldValue, - Object? photoUrl = _sentinel, - FieldValue? photoUrlFieldValue, - Object? updatedAt = _sentinel, - FieldValue? updatedAtFieldValue, - Object? createdAt = _sentinel, - FieldValue? createdAtFieldValue, - }) async { - assert( - name == _sentinel || nameFieldValue == null, - "Cannot specify both name and nameFieldValue", - ); - assert( - email == _sentinel || emailFieldValue == null, - "Cannot specify both email and emailFieldValue", - ); - assert( - photoUrl == _sentinel || photoUrlFieldValue == null, - "Cannot specify both photoUrl and photoUrlFieldValue", - ); - assert( - updatedAt == _sentinel || updatedAtFieldValue == null, - "Cannot specify both updatedAt and updatedAtFieldValue", - ); - assert( - createdAt == _sentinel || createdAtFieldValue == null, - "Cannot specify both createdAt and createdAtFieldValue", - ); - final json = { - if (name != _sentinel) - _$$UserImplFieldMap['name']!: - _$$UserImplPerFieldToJson.name(name as String), - if (nameFieldValue != null) _$$UserImplFieldMap['name']!: nameFieldValue, - if (email != _sentinel) - _$$UserImplFieldMap['email']!: - _$$UserImplPerFieldToJson.email(email as String), - if (emailFieldValue != null) - _$$UserImplFieldMap['email']!: emailFieldValue, - if (photoUrl != _sentinel) - _$$UserImplFieldMap['photoUrl']!: - _$$UserImplPerFieldToJson.photoUrl(photoUrl as String?), - if (photoUrlFieldValue != null) - _$$UserImplFieldMap['photoUrl']!: photoUrlFieldValue, - if (updatedAt != _sentinel) - _$$UserImplFieldMap['updatedAt']!: - _$$UserImplPerFieldToJson.updatedAt(updatedAt as UnionTimestamp), - if (updatedAtFieldValue != null) - _$$UserImplFieldMap['updatedAt']!: updatedAtFieldValue, - if (createdAt != _sentinel) - _$$UserImplFieldMap['createdAt']!: - _$$UserImplPerFieldToJson.createdAt(createdAt as UnionTimestamp), - if (createdAtFieldValue != null) - _$$UserImplFieldMap['createdAt']!: createdAtFieldValue, - }; - - return reference.update(json); - } - - void transactionUpdate( - Transaction transaction, { - Object? name = _sentinel, - FieldValue? nameFieldValue, - Object? email = _sentinel, - FieldValue? emailFieldValue, - Object? photoUrl = _sentinel, - FieldValue? photoUrlFieldValue, - Object? updatedAt = _sentinel, - FieldValue? updatedAtFieldValue, - Object? createdAt = _sentinel, - FieldValue? createdAtFieldValue, - }) { - assert( - name == _sentinel || nameFieldValue == null, - "Cannot specify both name and nameFieldValue", - ); - assert( - email == _sentinel || emailFieldValue == null, - "Cannot specify both email and emailFieldValue", - ); - assert( - photoUrl == _sentinel || photoUrlFieldValue == null, - "Cannot specify both photoUrl and photoUrlFieldValue", - ); - assert( - updatedAt == _sentinel || updatedAtFieldValue == null, - "Cannot specify both updatedAt and updatedAtFieldValue", - ); - assert( - createdAt == _sentinel || createdAtFieldValue == null, - "Cannot specify both createdAt and createdAtFieldValue", - ); - final json = { - if (name != _sentinel) - _$$UserImplFieldMap['name']!: - _$$UserImplPerFieldToJson.name(name as String), - if (nameFieldValue != null) _$$UserImplFieldMap['name']!: nameFieldValue, - if (email != _sentinel) - _$$UserImplFieldMap['email']!: - _$$UserImplPerFieldToJson.email(email as String), - if (emailFieldValue != null) - _$$UserImplFieldMap['email']!: emailFieldValue, - if (photoUrl != _sentinel) - _$$UserImplFieldMap['photoUrl']!: - _$$UserImplPerFieldToJson.photoUrl(photoUrl as String?), - if (photoUrlFieldValue != null) - _$$UserImplFieldMap['photoUrl']!: photoUrlFieldValue, - if (updatedAt != _sentinel) - _$$UserImplFieldMap['updatedAt']!: - _$$UserImplPerFieldToJson.updatedAt(updatedAt as UnionTimestamp), - if (updatedAtFieldValue != null) - _$$UserImplFieldMap['updatedAt']!: updatedAtFieldValue, - if (createdAt != _sentinel) - _$$UserImplFieldMap['createdAt']!: - _$$UserImplPerFieldToJson.createdAt(createdAt as UnionTimestamp), - if (createdAtFieldValue != null) - _$$UserImplFieldMap['createdAt']!: createdAtFieldValue, - }; - - transaction.update(reference, json); - } - - @override - bool operator ==(Object other) { - return other is UserDocumentReference && - other.runtimeType == runtimeType && - other.parent == parent && - other.id == id; - } - - @override - int get hashCode => Object.hash(runtimeType, parent, id); -} - -abstract class UserQuery implements QueryReference { - @override - UserQuery limit(int limit); - - @override - UserQuery limitToLast(int limit); - - /// 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'); - /// ``` - UserQuery orderByFieldPath( - FieldPath fieldPath, { - bool descending = false, - Object? startAt, - Object? startAfter, - Object? endAt, - Object? endBefore, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }); - - /// 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'); - /// ``` - UserQuery whereFieldPath( - FieldPath fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }); - - UserQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - UserQuery whereName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - UserQuery whereEmail({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - UserQuery wherePhotoUrl({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - UserQuery whereUpdatedAt({ - UnionTimestamp? isEqualTo, - UnionTimestamp? isNotEqualTo, - UnionTimestamp? isLessThan, - UnionTimestamp? isLessThanOrEqualTo, - UnionTimestamp? isGreaterThan, - UnionTimestamp? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - UserQuery whereCreatedAt({ - UnionTimestamp? isEqualTo, - UnionTimestamp? isNotEqualTo, - UnionTimestamp? isLessThan, - UnionTimestamp? isLessThanOrEqualTo, - UnionTimestamp? isGreaterThan, - UnionTimestamp? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }); - - UserQuery orderByDocumentId({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }); - - UserQuery orderByName({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }); - - UserQuery orderByEmail({ - bool descending = false, - String startAt, - String startAfter, - String endAt, - String endBefore, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }); - - UserQuery orderByPhotoUrl({ - bool descending = false, - String? startAt, - String? startAfter, - String? endAt, - String? endBefore, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }); - - UserQuery orderByUpdatedAt({ - bool descending = false, - UnionTimestamp startAt, - UnionTimestamp startAfter, - UnionTimestamp endAt, - UnionTimestamp endBefore, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }); - - UserQuery orderByCreatedAt({ - bool descending = false, - UnionTimestamp startAt, - UnionTimestamp startAfter, - UnionTimestamp endAt, - UnionTimestamp endBefore, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }); -} - -class _$UserQuery extends QueryReference - implements UserQuery { - _$UserQuery( - 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(UserQuerySnapshot._fromQuerySnapshot); - } - - @override - Future get([GetOptions? options]) { - return reference.get(options).then(UserQuerySnapshot._fromQuerySnapshot); - } - - @override - UserQuery limit(int limit) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limit(limit), - $queryCursor: $queryCursor, - ); - } - - @override - UserQuery limitToLast(int limit) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.limitToLast(limit), - $queryCursor: $queryCursor, - ); - } - - UserQuery orderByFieldPath( - FieldPath fieldPath, { - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? 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 _$UserQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - UserQuery whereFieldPath( - FieldPath fieldPath, { - Object? isEqualTo, - Object? isNotEqualTo, - Object? isLessThan, - Object? isLessThanOrEqualTo, - Object? isGreaterThan, - Object? isGreaterThanOrEqualTo, - Object? arrayContains, - List? arrayContainsAny, - List? whereIn, - List? whereNotIn, - bool? isNull, - }) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - fieldPath, - isEqualTo: isEqualTo, - isNotEqualTo: isNotEqualTo, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - arrayContains: arrayContains, - arrayContainsAny: arrayContainsAny, - whereIn: whereIn, - whereNotIn: whereNotIn, - isNull: isNull, - ), - $queryCursor: $queryCursor, - ); - } - - UserQuery whereDocumentId({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - FieldPath.documentId, - isEqualTo: isEqualTo, - isNotEqualTo: isNotEqualTo, - isLessThan: isLessThan, - isLessThanOrEqualTo: isLessThanOrEqualTo, - isGreaterThan: isGreaterThan, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, - isNull: isNull, - whereIn: whereIn, - whereNotIn: whereNotIn, - ), - $queryCursor: $queryCursor, - ); - } - - UserQuery whereName({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$UserImplFieldMap['name']!, - isEqualTo: isEqualTo != null - ? _$$UserImplPerFieldToJson.name(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$UserImplPerFieldToJson.name(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$UserImplPerFieldToJson.name(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.name(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$UserImplPerFieldToJson.name(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.name(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$UserImplPerFieldToJson.name(e)), - whereNotIn: whereNotIn?.map((e) => _$$UserImplPerFieldToJson.name(e)), - ), - $queryCursor: $queryCursor, - ); - } - - UserQuery whereEmail({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$UserImplFieldMap['email']!, - isEqualTo: isEqualTo != null - ? _$$UserImplPerFieldToJson.email(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$UserImplPerFieldToJson.email(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$UserImplPerFieldToJson.email(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.email(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$UserImplPerFieldToJson.email(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.email(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$UserImplPerFieldToJson.email(e)), - whereNotIn: whereNotIn?.map((e) => _$$UserImplPerFieldToJson.email(e)), - ), - $queryCursor: $queryCursor, - ); - } - - UserQuery wherePhotoUrl({ - String? isEqualTo, - String? isNotEqualTo, - String? isLessThan, - String? isLessThanOrEqualTo, - String? isGreaterThan, - String? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$UserImplFieldMap['photoUrl']!, - isEqualTo: isEqualTo != null - ? _$$UserImplPerFieldToJson.photoUrl(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$UserImplPerFieldToJson.photoUrl(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$UserImplPerFieldToJson.photoUrl(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.photoUrl(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$UserImplPerFieldToJson.photoUrl(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.photoUrl(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$UserImplPerFieldToJson.photoUrl(e)), - whereNotIn: - whereNotIn?.map((e) => _$$UserImplPerFieldToJson.photoUrl(e)), - ), - $queryCursor: $queryCursor, - ); - } - - UserQuery whereUpdatedAt({ - UnionTimestamp? isEqualTo, - UnionTimestamp? isNotEqualTo, - UnionTimestamp? isLessThan, - UnionTimestamp? isLessThanOrEqualTo, - UnionTimestamp? isGreaterThan, - UnionTimestamp? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$UserImplFieldMap['updatedAt']!, - isEqualTo: isEqualTo != null - ? _$$UserImplPerFieldToJson.updatedAt(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$UserImplPerFieldToJson.updatedAt(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$UserImplPerFieldToJson.updatedAt(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.updatedAt(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$UserImplPerFieldToJson.updatedAt(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.updatedAt(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$UserImplPerFieldToJson.updatedAt(e)), - whereNotIn: - whereNotIn?.map((e) => _$$UserImplPerFieldToJson.updatedAt(e)), - ), - $queryCursor: $queryCursor, - ); - } - - UserQuery whereCreatedAt({ - UnionTimestamp? isEqualTo, - UnionTimestamp? isNotEqualTo, - UnionTimestamp? isLessThan, - UnionTimestamp? isLessThanOrEqualTo, - UnionTimestamp? isGreaterThan, - UnionTimestamp? isGreaterThanOrEqualTo, - bool? isNull, - List? whereIn, - List? whereNotIn, - }) { - return _$UserQuery( - _collection, - $referenceWithoutCursor: $referenceWithoutCursor.where( - _$$UserImplFieldMap['createdAt']!, - isEqualTo: isEqualTo != null - ? _$$UserImplPerFieldToJson.createdAt(isEqualTo) - : null, - isNotEqualTo: isNotEqualTo != null - ? _$$UserImplPerFieldToJson.createdAt(isNotEqualTo) - : null, - isLessThan: isLessThan != null - ? _$$UserImplPerFieldToJson.createdAt(isLessThan) - : null, - isLessThanOrEqualTo: isLessThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.createdAt(isLessThanOrEqualTo) - : null, - isGreaterThan: isGreaterThan != null - ? _$$UserImplPerFieldToJson.createdAt(isGreaterThan) - : null, - isGreaterThanOrEqualTo: isGreaterThanOrEqualTo != null - ? _$$UserImplPerFieldToJson.createdAt(isGreaterThanOrEqualTo) - : null, - isNull: isNull, - whereIn: whereIn?.map((e) => _$$UserImplPerFieldToJson.createdAt(e)), - whereNotIn: - whereNotIn?.map((e) => _$$UserImplPerFieldToJson.createdAt(e)), - ), - $queryCursor: $queryCursor, - ); - } - - UserQuery orderByDocumentId({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? 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 _$UserQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - UserQuery orderByName({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$$UserImplFieldMap['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, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$UserQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - UserQuery orderByEmail({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor.orderBy(_$$UserImplFieldMap['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, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$UserQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - UserQuery orderByPhotoUrl({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$$UserImplFieldMap['photoUrl']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$UserQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - UserQuery orderByUpdatedAt({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$$UserImplFieldMap['updatedAt']!, descending: descending); - var queryCursor = $queryCursor; - - if (startAtDocument != null) { - queryCursor = queryCursor.copyWith( - startAt: const [], - startAtDocumentSnapshot: startAtDocument.snapshot, - ); - } - if (startAfterDocument != null) { - queryCursor = queryCursor.copyWith( - startAfter: const [], - startAfterDocumentSnapshot: startAfterDocument.snapshot, - ); - } - if (endAtDocument != null) { - queryCursor = queryCursor.copyWith( - endAt: const [], - endAtDocumentSnapshot: endAtDocument.snapshot, - ); - } - if (endBeforeDocument != null) { - queryCursor = queryCursor.copyWith( - endBefore: const [], - endBeforeDocumentSnapshot: endBeforeDocument.snapshot, - ); - } - - if (startAt != _sentinel) { - queryCursor = queryCursor.copyWith( - startAt: [...queryCursor.startAt, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$UserQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - UserQuery orderByCreatedAt({ - bool descending = false, - Object? startAt = _sentinel, - Object? startAfter = _sentinel, - Object? endAt = _sentinel, - Object? endBefore = _sentinel, - UserDocumentSnapshot? startAtDocument, - UserDocumentSnapshot? endAtDocument, - UserDocumentSnapshot? endBeforeDocument, - UserDocumentSnapshot? startAfterDocument, - }) { - final query = $referenceWithoutCursor - .orderBy(_$$UserImplFieldMap['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, startAt], - startAtDocumentSnapshot: null, - ); - } - if (startAfter != _sentinel) { - queryCursor = queryCursor.copyWith( - startAfter: [...queryCursor.startAfter, startAfter], - startAfterDocumentSnapshot: null, - ); - } - if (endAt != _sentinel) { - queryCursor = queryCursor.copyWith( - endAt: [...queryCursor.endAt, endAt], - endAtDocumentSnapshot: null, - ); - } - if (endBefore != _sentinel) { - queryCursor = queryCursor.copyWith( - endBefore: [...queryCursor.endBefore, endBefore], - endBeforeDocumentSnapshot: null, - ); - } - - return _$UserQuery( - _collection, - $referenceWithoutCursor: query, - $queryCursor: queryCursor, - ); - } - - @override - bool operator ==(Object other) { - return other is _$UserQuery && - other.runtimeType == runtimeType && - other.reference == reference; - } - - @override - int get hashCode => Object.hash(runtimeType, reference); -} - -class UserDocumentSnapshot extends FirestoreDocumentSnapshot { - UserDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final DocumentSnapshot snapshot; - - @override - UserDocumentReference get reference { - return UserDocumentReference( - snapshot.reference, - ); - } - - @override - final User? data; -} - -class UserQuerySnapshot - extends FirestoreQuerySnapshot { - UserQuerySnapshot._( - this.snapshot, - this.docs, - this.docChanges, - ); - - factory UserQuerySnapshot._fromQuerySnapshot( - QuerySnapshot snapshot, - ) { - final docs = snapshot.docs.map(UserQueryDocumentSnapshot._).toList(); - - final docChanges = snapshot.docChanges.map((change) { - return _decodeDocumentChange( - change, - UserDocumentSnapshot._, - ); - }).toList(); - - return UserQuerySnapshot._( - snapshot, - docs, - docChanges, - ); - } - - static FirestoreDocumentChange _decodeDocumentChange( - DocumentChange docChange, - UserDocumentSnapshot 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 UserQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot - implements UserDocumentSnapshot { - UserQueryDocumentSnapshot._(this.snapshot) : data = snapshot.data(); - - @override - final QueryDocumentSnapshot snapshot; - - @override - final User data; - - @override - UserDocumentReference get reference { - return UserDocumentReference(snapshot.reference); - } -} - // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** diff --git a/pubspec.lock b/pubspec.lock index 1156d4cf..f820294c 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -249,22 +249,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.13.0" - cloud_firestore_odm: - dependency: "direct main" - description: - name: cloud_firestore_odm - sha256: b46ace189cd85e23f76aece7d5e2a3d0e6cf992bf685e71486372dcebadcdf96 - url: "https://pub.dev" - source: hosted - version: "1.0.0-dev.75" - cloud_firestore_odm_generator: - dependency: "direct dev" - description: - name: cloud_firestore_odm_generator - sha256: "85b8f2970b0d566a5ca30aec2f7f591d14aca11b888d4b760880fba456d54cb6" - url: "https://pub.dev" - source: hosted - version: "1.0.0-dev.75" cloud_firestore_platform_interface: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index c78ec748..4171d539 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -11,7 +11,6 @@ dependencies: adaptive_theme: ^3.4.1 cached_network_image: ^3.3.0 cloud_firestore: ^4.13.0 - cloud_firestore_odm: ^1.0.0-dev.75 cupertino_icons: ^1.0.6 # 未マージのためgit指定 # ref. https://github.com/invertase/flutter_desktop_webview_auth/pull/51 @@ -49,10 +48,8 @@ dependencies: version: ^3.0.2 dev_dependencies: - # `cloud_firestore_odm_generator`が^5.12.0依存 - analyzer: ^5.12.0 + analyzer: ^5.13.0 build_runner: ^2.4.6 - cloud_firestore_odm_generator: ^1.0.0-dev.73 custom_lint: ^0.5.6 flutter_gen: ^5.3.2 flutter_gen_runner: ^5.3.2