diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/.metadata b/packages/cloud_firestore_odm/cloud_firestore_odm/example/.metadata index a5584fc372d9..3ef76cb126d8 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/example/.metadata +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/.metadata @@ -1,10 +1,42 @@ # This file tracks properties of this Flutter project. # Used by Flutter tool to assess capabilities and perform upgrades etc. # -# This file should be version controlled and should not be manually edited. +# This file should be version controlled. version: - revision: 18116933e77adc82f80866c928266a5b4f1ed645 - channel: stable + revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + channel: dev project_type: app + +# Tracks metadata for the flutter migrate command +migration: + platforms: + - platform: root + create_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + base_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + - platform: android + create_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + base_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + - platform: ios + create_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + base_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + - platform: macos + create_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + base_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + - platform: web + create_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + base_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + - platform: windows + create_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + base_revision: 8662e22bac54c71bc4fa5a4f37e9ee80bfd08a4e + + # User provided section + + # List of Local paths (relative to this file) that should be + # ignored by the migrate tool. + # + # Files that are not part of the templates will be ignored by default. + unmanaged_files: + - 'lib/main.dart' + - 'ios/Runner.xcodeproj/project.pbxproj' diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/build.yaml b/packages/cloud_firestore_odm/cloud_firestore_odm/example/build.yaml index 7ba05383c0c5..097810706d00 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/example/build.yaml +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/build.yaml @@ -1,6 +1,25 @@ targets: $default: builders: + cloud_firestore_odm_generator: + enabled: true + generate_for: + include: + - lib/* + - lib/** + - test_driver/integration/* + - test_driver/integration/**/* json_serializable: + enabled: true + generate_for: + include: + - lib/* + - lib/** + - test_driver/integration/* + - test_driver/integration/**/* options: - create_field_map: true \ No newline at end of file + create_field_map: true + source_gen|combining_builder: + options: + ignore_for_file: + - 'type=lint' diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration.g.dart b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration.g.dart index a6d40c8e65e6..49c62ec9ece0 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration.g.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration.g.dart @@ -1,5 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + part of 'integration.dart'; // ************************************************************************** diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/query.dart b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/query.dart new file mode 100644 index 000000000000..a5c462617b9a --- /dev/null +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/query.dart @@ -0,0 +1,55 @@ +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.g.dart'; + +@Collection('firestore-example-app/42/date-time') +final dateTimeQueryRef = DateTimeQueryCollectionReference(); + +@JsonSerializable() +@FirestoreDateTimeConverter() +class DateTimeQuery { + DateTimeQuery(this.time); + final DateTime time; +} + +class FirestoreDateTimeConverter extends JsonConverter { + const FirestoreDateTimeConverter(); + @override + DateTime fromJson(Timestamp json) => json.toDate(); + + @override + Timestamp toJson(DateTime object) => Timestamp.fromDate(object); +} + +@Collection('firestore-example-app/42/timestamp-time') +final timestampQueryRef = TimestampQueryCollectionReference(); + +@JsonSerializable() +@FirestoreTimestampConverter() +class TimestampQuery { + TimestampQuery(this.time); + final Timestamp time; +} + +@Collection('firestore-example-app/42/geopoint-time') +final geoPointQueryRef = GeoPointQueryCollectionReference(); + +@JsonSerializable() +@FirestoreGeoPointConverter() +class GeoPointQuery { + GeoPointQuery(this.point); + final GeoPoint point; +} + +@Collection('firestore-example-app/42/doc-ref') +final documentReferenceRef = DocumentReferenceQueryCollectionReference(); + +@JsonSerializable() +@FirestoreDocumentReferenceConverter() +class DocumentReferenceQuery { + DocumentReferenceQuery(this.ref); + + final DocumentReference> ref; +} diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/query.g.dart b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/query.g.dart new file mode 100644 index 000000000000..4fbd5dfd490b --- /dev/null +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/integration/query.g.dart @@ -0,0 +1,2109 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ignore_for_file: type=lint + +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 + +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 DateTimeQueryCollectionReference + implements + DateTimeQueryQuery, + FirestoreCollectionReference { + factory DateTimeQueryCollectionReference([ + FirebaseFirestore? firestore, + ]) = _$DateTimeQueryCollectionReference; + + static DateTimeQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$DateTimeQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + DateTimeQuery value, + SetOptions? options, + ) { + return _$DateTimeQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + DateTimeQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(DateTimeQuery value); +} + +class _$DateTimeQueryCollectionReference extends _$DateTimeQueryQuery + implements DateTimeQueryCollectionReference { + factory _$DateTimeQueryCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$DateTimeQueryCollectionReference._( + firestore.collection('firestore-example-app/42/date-time').withConverter( + fromFirestore: DateTimeQueryCollectionReference.fromFirestore, + toFirestore: DateTimeQueryCollectionReference.toFirestore, + ), + ); + } + + _$DateTimeQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + DateTimeQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return DateTimeQueryDocumentReference( + reference.doc(id), + ); + } + + @override + Future add(DateTimeQuery value) { + return reference + .add(value) + .then((ref) => DateTimeQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$DateTimeQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class DateTimeQueryDocumentReference + extends FirestoreDocumentReference { + factory DateTimeQueryDocumentReference( + DocumentReference reference) = + _$DateTimeQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [DateTimeQueryCollectionReference] containing this document. + DateTimeQueryCollectionReference get parent { + return _$DateTimeQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + Future update({ + DateTime time, + }); + + Future set(DateTimeQuery value); +} + +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((snapshot) { + return DateTimeQueryDocumentSnapshot._( + snapshot, + snapshot.data(), + ); + }); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then((snapshot) { + return DateTimeQueryDocumentSnapshot._( + snapshot, + snapshot.data(), + ); + }); + } + + @override + Future delete() { + return reference.delete(); + } + + Future update({ + Object? time = _sentinel, + }) async { + final json = { + if (time != _sentinel) "time": time as DateTime, + }; + + return reference.update(json); + } + + Future set(DateTimeQuery value) { + return reference.set(value); + } + + @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); +} + +class DateTimeQueryDocumentSnapshot extends FirestoreDocumentSnapshot { + DateTimeQueryDocumentSnapshot._( + this.snapshot, + this.data, + ); + + @override + final DocumentSnapshot snapshot; + + @override + DateTimeQueryDocumentReference get reference { + return DateTimeQueryDocumentReference( + snapshot.reference, + ); + } + + @override + final DateTimeQuery? data; +} + +abstract class DateTimeQueryQuery + implements QueryReference { + @override + DateTimeQueryQuery limit(int limit); + + @override + DateTimeQueryQuery limitToLast(int limit); + + DateTimeQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + DateTimeQueryQuery whereTime({ + DateTime? isEqualTo, + DateTime? isNotEqualTo, + DateTime? isLessThan, + DateTime? isLessThanOrEqualTo, + DateTime? isGreaterThan, + DateTime? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + + 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.reference, + this._collection, + ); + + final CollectionReference _collection; + + @override + final Query reference; + + DateTimeQueryQuerySnapshot _decodeSnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map((e) { + return DateTimeQueryQueryDocumentSnapshot._(e, e.data()); + }).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return FirestoreDocumentChange( + type: change.type, + oldIndex: change.oldIndex, + newIndex: change.newIndex, + doc: DateTimeQueryDocumentSnapshot._(change.doc, change.doc.data()), + ); + }).toList(); + + return DateTimeQueryQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(_decodeSnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(_decodeSnapshot); + } + + @override + DateTimeQueryQuery limit(int limit) { + return _$DateTimeQueryQuery( + reference.limit(limit), + _collection, + ); + } + + @override + DateTimeQueryQuery limitToLast(int limit) { + return _$DateTimeQueryQuery( + reference.limitToLast(limit), + _collection, + ); + } + + DateTimeQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$DateTimeQueryQuery( + reference.where( + FieldPath.documentId, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + _collection, + ); + } + + DateTimeQueryQuery whereTime({ + DateTime? isEqualTo, + DateTime? isNotEqualTo, + DateTime? isLessThan, + DateTime? isLessThanOrEqualTo, + DateTime? isGreaterThan, + DateTime? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$DateTimeQueryQuery( + reference.where( + _$DateTimeQueryFieldMap["time"]!, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + _collection, + ); + } + + 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, + }) { + var query = reference.orderBy(FieldPath.documentId, descending: descending); + + if (startAtDocument != null) { + query = query.startAtDocument(startAtDocument.snapshot); + } + if (startAfterDocument != null) { + query = query.startAfterDocument(startAfterDocument.snapshot); + } + if (endAtDocument != null) { + query = query.endAtDocument(endAtDocument.snapshot); + } + if (endBeforeDocument != null) { + query = query.endBeforeDocument(endBeforeDocument.snapshot); + } + + if (startAt != _sentinel) { + query = query.startAt([startAt]); + } + if (startAfter != _sentinel) { + query = query.startAfter([startAfter]); + } + if (endAt != _sentinel) { + query = query.endAt([endAt]); + } + if (endBefore != _sentinel) { + query = query.endBefore([endBefore]); + } + + return _$DateTimeQueryQuery(query, _collection); + } + + 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, + }) { + var query = reference.orderBy(_$DateTimeQueryFieldMap["time"]!, + descending: descending); + + if (startAtDocument != null) { + query = query.startAtDocument(startAtDocument.snapshot); + } + if (startAfterDocument != null) { + query = query.startAfterDocument(startAfterDocument.snapshot); + } + if (endAtDocument != null) { + query = query.endAtDocument(endAtDocument.snapshot); + } + if (endBeforeDocument != null) { + query = query.endBeforeDocument(endBeforeDocument.snapshot); + } + + if (startAt != _sentinel) { + query = query.startAt([startAt]); + } + if (startAfter != _sentinel) { + query = query.startAfter([startAfter]); + } + if (endAt != _sentinel) { + query = query.endAt([endAt]); + } + if (endBefore != _sentinel) { + query = query.endBefore([endBefore]); + } + + return _$DateTimeQueryQuery(query, _collection); + } + + @override + bool operator ==(Object other) { + return other is _$DateTimeQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class DateTimeQueryQuerySnapshot + extends FirestoreQuerySnapshot { + DateTimeQueryQuerySnapshot._( + this.snapshot, + this.docs, + this.docChanges, + ); + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class DateTimeQueryQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements DateTimeQueryDocumentSnapshot { + DateTimeQueryQueryDocumentSnapshot._(this.snapshot, this.data); + + @override + final QueryDocumentSnapshot snapshot; + + @override + DateTimeQueryDocumentReference get reference { + return DateTimeQueryDocumentReference(snapshot.reference); + } + + @override + final DateTimeQuery data; +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class TimestampQueryCollectionReference + implements + TimestampQueryQuery, + FirestoreCollectionReference { + factory TimestampQueryCollectionReference([ + FirebaseFirestore? firestore, + ]) = _$TimestampQueryCollectionReference; + + static TimestampQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$TimestampQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + TimestampQuery value, + SetOptions? options, + ) { + return _$TimestampQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + TimestampQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(TimestampQuery value); +} + +class _$TimestampQueryCollectionReference extends _$TimestampQueryQuery + implements TimestampQueryCollectionReference { + factory _$TimestampQueryCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$TimestampQueryCollectionReference._( + firestore + .collection('firestore-example-app/42/timestamp-time') + .withConverter( + fromFirestore: TimestampQueryCollectionReference.fromFirestore, + toFirestore: TimestampQueryCollectionReference.toFirestore, + ), + ); + } + + _$TimestampQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + TimestampQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return TimestampQueryDocumentReference( + reference.doc(id), + ); + } + + @override + Future add(TimestampQuery value) { + return reference + .add(value) + .then((ref) => TimestampQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$TimestampQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class TimestampQueryDocumentReference + extends FirestoreDocumentReference { + factory TimestampQueryDocumentReference( + DocumentReference reference) = + _$TimestampQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [TimestampQueryCollectionReference] containing this document. + TimestampQueryCollectionReference get parent { + return _$TimestampQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + Future update({ + Timestamp time, + }); + + Future set(TimestampQuery value); +} + +class _$TimestampQueryDocumentReference + extends FirestoreDocumentReference + 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((snapshot) { + return TimestampQueryDocumentSnapshot._( + snapshot, + snapshot.data(), + ); + }); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then((snapshot) { + return TimestampQueryDocumentSnapshot._( + snapshot, + snapshot.data(), + ); + }); + } + + @override + Future delete() { + return reference.delete(); + } + + Future update({ + Object? time = _sentinel, + }) async { + final json = { + if (time != _sentinel) "time": time as Timestamp, + }; + + return reference.update(json); + } + + Future set(TimestampQuery value) { + return reference.set(value); + } + + @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); +} + +class TimestampQueryDocumentSnapshot extends FirestoreDocumentSnapshot { + TimestampQueryDocumentSnapshot._( + this.snapshot, + this.data, + ); + + @override + final DocumentSnapshot snapshot; + + @override + TimestampQueryDocumentReference get reference { + return TimestampQueryDocumentReference( + snapshot.reference, + ); + } + + @override + final TimestampQuery? data; +} + +abstract class TimestampQueryQuery + implements QueryReference { + @override + TimestampQueryQuery limit(int limit); + + @override + TimestampQueryQuery limitToLast(int limit); + + TimestampQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + TimestampQueryQuery whereTime({ + Timestamp? isEqualTo, + Timestamp? isNotEqualTo, + Timestamp? isLessThan, + Timestamp? isLessThanOrEqualTo, + Timestamp? isGreaterThan, + Timestamp? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + + 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.reference, + this._collection, + ); + + final CollectionReference _collection; + + @override + final Query reference; + + TimestampQueryQuerySnapshot _decodeSnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map((e) { + return TimestampQueryQueryDocumentSnapshot._(e, e.data()); + }).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return FirestoreDocumentChange( + type: change.type, + oldIndex: change.oldIndex, + newIndex: change.newIndex, + doc: TimestampQueryDocumentSnapshot._(change.doc, change.doc.data()), + ); + }).toList(); + + return TimestampQueryQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(_decodeSnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(_decodeSnapshot); + } + + @override + TimestampQueryQuery limit(int limit) { + return _$TimestampQueryQuery( + reference.limit(limit), + _collection, + ); + } + + @override + TimestampQueryQuery limitToLast(int limit) { + return _$TimestampQueryQuery( + reference.limitToLast(limit), + _collection, + ); + } + + TimestampQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$TimestampQueryQuery( + reference.where( + FieldPath.documentId, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + _collection, + ); + } + + TimestampQueryQuery whereTime({ + Timestamp? isEqualTo, + Timestamp? isNotEqualTo, + Timestamp? isLessThan, + Timestamp? isLessThanOrEqualTo, + Timestamp? isGreaterThan, + Timestamp? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$TimestampQueryQuery( + reference.where( + _$TimestampQueryFieldMap["time"]!, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + _collection, + ); + } + + 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, + }) { + var query = reference.orderBy(FieldPath.documentId, descending: descending); + + if (startAtDocument != null) { + query = query.startAtDocument(startAtDocument.snapshot); + } + if (startAfterDocument != null) { + query = query.startAfterDocument(startAfterDocument.snapshot); + } + if (endAtDocument != null) { + query = query.endAtDocument(endAtDocument.snapshot); + } + if (endBeforeDocument != null) { + query = query.endBeforeDocument(endBeforeDocument.snapshot); + } + + if (startAt != _sentinel) { + query = query.startAt([startAt]); + } + if (startAfter != _sentinel) { + query = query.startAfter([startAfter]); + } + if (endAt != _sentinel) { + query = query.endAt([endAt]); + } + if (endBefore != _sentinel) { + query = query.endBefore([endBefore]); + } + + return _$TimestampQueryQuery(query, _collection); + } + + 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, + }) { + var query = reference.orderBy(_$TimestampQueryFieldMap["time"]!, + descending: descending); + + if (startAtDocument != null) { + query = query.startAtDocument(startAtDocument.snapshot); + } + if (startAfterDocument != null) { + query = query.startAfterDocument(startAfterDocument.snapshot); + } + if (endAtDocument != null) { + query = query.endAtDocument(endAtDocument.snapshot); + } + if (endBeforeDocument != null) { + query = query.endBeforeDocument(endBeforeDocument.snapshot); + } + + if (startAt != _sentinel) { + query = query.startAt([startAt]); + } + if (startAfter != _sentinel) { + query = query.startAfter([startAfter]); + } + if (endAt != _sentinel) { + query = query.endAt([endAt]); + } + if (endBefore != _sentinel) { + query = query.endBefore([endBefore]); + } + + return _$TimestampQueryQuery(query, _collection); + } + + @override + bool operator ==(Object other) { + return other is _$TimestampQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class TimestampQueryQuerySnapshot + extends FirestoreQuerySnapshot { + TimestampQueryQuerySnapshot._( + this.snapshot, + this.docs, + this.docChanges, + ); + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> + docChanges; +} + +class TimestampQueryQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements TimestampQueryDocumentSnapshot { + TimestampQueryQueryDocumentSnapshot._(this.snapshot, this.data); + + @override + final QueryDocumentSnapshot snapshot; + + @override + TimestampQueryDocumentReference get reference { + return TimestampQueryDocumentReference(snapshot.reference); + } + + @override + final TimestampQuery data; +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class GeoPointQueryCollectionReference + implements + GeoPointQueryQuery, + FirestoreCollectionReference { + factory GeoPointQueryCollectionReference([ + FirebaseFirestore? firestore, + ]) = _$GeoPointQueryCollectionReference; + + static GeoPointQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$GeoPointQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + GeoPointQuery value, + SetOptions? options, + ) { + return _$GeoPointQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + GeoPointQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add(GeoPointQuery value); +} + +class _$GeoPointQueryCollectionReference extends _$GeoPointQueryQuery + implements GeoPointQueryCollectionReference { + factory _$GeoPointQueryCollectionReference([FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$GeoPointQueryCollectionReference._( + firestore + .collection('firestore-example-app/42/geopoint-time') + .withConverter( + fromFirestore: GeoPointQueryCollectionReference.fromFirestore, + toFirestore: GeoPointQueryCollectionReference.toFirestore, + ), + ); + } + + _$GeoPointQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + GeoPointQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return GeoPointQueryDocumentReference( + reference.doc(id), + ); + } + + @override + Future add(GeoPointQuery value) { + return reference + .add(value) + .then((ref) => GeoPointQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$GeoPointQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class GeoPointQueryDocumentReference + extends FirestoreDocumentReference { + factory GeoPointQueryDocumentReference( + DocumentReference reference) = + _$GeoPointQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [GeoPointQueryCollectionReference] containing this document. + GeoPointQueryCollectionReference get parent { + return _$GeoPointQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + Future update({ + GeoPoint point, + }); + + Future set(GeoPointQuery value); +} + +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((snapshot) { + return GeoPointQueryDocumentSnapshot._( + snapshot, + snapshot.data(), + ); + }); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then((snapshot) { + return GeoPointQueryDocumentSnapshot._( + snapshot, + snapshot.data(), + ); + }); + } + + @override + Future delete() { + return reference.delete(); + } + + Future update({ + Object? point = _sentinel, + }) async { + final json = { + if (point != _sentinel) "point": point as GeoPoint, + }; + + return reference.update(json); + } + + Future set(GeoPointQuery value) { + return reference.set(value); + } + + @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); +} + +class GeoPointQueryDocumentSnapshot extends FirestoreDocumentSnapshot { + GeoPointQueryDocumentSnapshot._( + this.snapshot, + this.data, + ); + + @override + final DocumentSnapshot snapshot; + + @override + GeoPointQueryDocumentReference get reference { + return GeoPointQueryDocumentReference( + snapshot.reference, + ); + } + + @override + final GeoPointQuery? data; +} + +abstract class GeoPointQueryQuery + implements QueryReference { + @override + GeoPointQueryQuery limit(int limit); + + @override + GeoPointQueryQuery limitToLast(int limit); + + GeoPointQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + GeoPointQueryQuery wherePoint({ + GeoPoint? isEqualTo, + GeoPoint? isNotEqualTo, + GeoPoint? isLessThan, + GeoPoint? isLessThanOrEqualTo, + GeoPoint? isGreaterThan, + GeoPoint? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + + 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.reference, + this._collection, + ); + + final CollectionReference _collection; + + @override + final Query reference; + + GeoPointQueryQuerySnapshot _decodeSnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map((e) { + return GeoPointQueryQueryDocumentSnapshot._(e, e.data()); + }).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return FirestoreDocumentChange( + type: change.type, + oldIndex: change.oldIndex, + newIndex: change.newIndex, + doc: GeoPointQueryDocumentSnapshot._(change.doc, change.doc.data()), + ); + }).toList(); + + return GeoPointQueryQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + @override + Stream snapshots([SnapshotOptions? options]) { + return reference.snapshots().map(_decodeSnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(_decodeSnapshot); + } + + @override + GeoPointQueryQuery limit(int limit) { + return _$GeoPointQueryQuery( + reference.limit(limit), + _collection, + ); + } + + @override + GeoPointQueryQuery limitToLast(int limit) { + return _$GeoPointQueryQuery( + reference.limitToLast(limit), + _collection, + ); + } + + GeoPointQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$GeoPointQueryQuery( + reference.where( + FieldPath.documentId, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + _collection, + ); + } + + GeoPointQueryQuery wherePoint({ + GeoPoint? isEqualTo, + GeoPoint? isNotEqualTo, + GeoPoint? isLessThan, + GeoPoint? isLessThanOrEqualTo, + GeoPoint? isGreaterThan, + GeoPoint? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$GeoPointQueryQuery( + reference.where( + _$GeoPointQueryFieldMap["point"]!, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + _collection, + ); + } + + 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, + }) { + var query = reference.orderBy(FieldPath.documentId, descending: descending); + + if (startAtDocument != null) { + query = query.startAtDocument(startAtDocument.snapshot); + } + if (startAfterDocument != null) { + query = query.startAfterDocument(startAfterDocument.snapshot); + } + if (endAtDocument != null) { + query = query.endAtDocument(endAtDocument.snapshot); + } + if (endBeforeDocument != null) { + query = query.endBeforeDocument(endBeforeDocument.snapshot); + } + + if (startAt != _sentinel) { + query = query.startAt([startAt]); + } + if (startAfter != _sentinel) { + query = query.startAfter([startAfter]); + } + if (endAt != _sentinel) { + query = query.endAt([endAt]); + } + if (endBefore != _sentinel) { + query = query.endBefore([endBefore]); + } + + return _$GeoPointQueryQuery(query, _collection); + } + + 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, + }) { + var query = reference.orderBy(_$GeoPointQueryFieldMap["point"]!, + descending: descending); + + if (startAtDocument != null) { + query = query.startAtDocument(startAtDocument.snapshot); + } + if (startAfterDocument != null) { + query = query.startAfterDocument(startAfterDocument.snapshot); + } + if (endAtDocument != null) { + query = query.endAtDocument(endAtDocument.snapshot); + } + if (endBeforeDocument != null) { + query = query.endBeforeDocument(endBeforeDocument.snapshot); + } + + if (startAt != _sentinel) { + query = query.startAt([startAt]); + } + if (startAfter != _sentinel) { + query = query.startAfter([startAfter]); + } + if (endAt != _sentinel) { + query = query.endAt([endAt]); + } + if (endBefore != _sentinel) { + query = query.endBefore([endBefore]); + } + + return _$GeoPointQueryQuery(query, _collection); + } + + @override + bool operator ==(Object other) { + return other is _$GeoPointQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class GeoPointQueryQuerySnapshot + extends FirestoreQuerySnapshot { + GeoPointQueryQuerySnapshot._( + this.snapshot, + this.docs, + this.docChanges, + ); + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> docChanges; +} + +class GeoPointQueryQueryDocumentSnapshot extends FirestoreQueryDocumentSnapshot + implements GeoPointQueryDocumentSnapshot { + GeoPointQueryQueryDocumentSnapshot._(this.snapshot, this.data); + + @override + final QueryDocumentSnapshot snapshot; + + @override + GeoPointQueryDocumentReference get reference { + return GeoPointQueryDocumentReference(snapshot.reference); + } + + @override + final GeoPointQuery data; +} + +/// A collection reference object can be used for adding documents, +/// getting document references, and querying for documents +/// (using the methods inherited from Query). +abstract class DocumentReferenceQueryCollectionReference + implements + DocumentReferenceQueryQuery, + FirestoreCollectionReference { + factory DocumentReferenceQueryCollectionReference([ + FirebaseFirestore? firestore, + ]) = _$DocumentReferenceQueryCollectionReference; + + static DocumentReferenceQuery fromFirestore( + DocumentSnapshot> snapshot, + SnapshotOptions? options, + ) { + return _$DocumentReferenceQueryFromJson(snapshot.data()!); + } + + static Map toFirestore( + DocumentReferenceQuery value, + SetOptions? options, + ) { + return _$DocumentReferenceQueryToJson(value); + } + + @override + CollectionReference get reference; + + @override + DocumentReferenceQueryDocumentReference doc([String? id]); + + /// Add a new document to this collection with the specified data, + /// assigning it a document ID automatically. + Future add( + DocumentReferenceQuery value); +} + +class _$DocumentReferenceQueryCollectionReference + extends _$DocumentReferenceQueryQuery + implements DocumentReferenceQueryCollectionReference { + factory _$DocumentReferenceQueryCollectionReference( + [FirebaseFirestore? firestore]) { + firestore ??= FirebaseFirestore.instance; + + return _$DocumentReferenceQueryCollectionReference._( + firestore.collection('firestore-example-app/42/doc-ref').withConverter( + fromFirestore: + DocumentReferenceQueryCollectionReference.fromFirestore, + toFirestore: DocumentReferenceQueryCollectionReference.toFirestore, + ), + ); + } + + _$DocumentReferenceQueryCollectionReference._( + CollectionReference reference, + ) : super(reference, reference); + + String get path => reference.path; + + @override + CollectionReference get reference => + super.reference as CollectionReference; + + @override + DocumentReferenceQueryDocumentReference doc([String? id]) { + assert( + id == null || id.split('/').length == 1, + 'The document ID cannot be from a different collection', + ); + return DocumentReferenceQueryDocumentReference( + reference.doc(id), + ); + } + + @override + Future add( + DocumentReferenceQuery value) { + return reference + .add(value) + .then((ref) => DocumentReferenceQueryDocumentReference(ref)); + } + + @override + bool operator ==(Object other) { + return other is _$DocumentReferenceQueryCollectionReference && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +abstract class DocumentReferenceQueryDocumentReference + extends FirestoreDocumentReference { + factory DocumentReferenceQueryDocumentReference( + DocumentReference reference) = + _$DocumentReferenceQueryDocumentReference; + + DocumentReference get reference; + + /// A reference to the [DocumentReferenceQueryCollectionReference] containing this document. + DocumentReferenceQueryCollectionReference get parent { + return _$DocumentReferenceQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots(); + + @override + Future get([GetOptions? options]); + + @override + Future delete(); + + Future update({ + DocumentReference> ref, + }); + + Future set(DocumentReferenceQuery value); +} + +class _$DocumentReferenceQueryDocumentReference + extends FirestoreDocumentReference + implements DocumentReferenceQueryDocumentReference { + _$DocumentReferenceQueryDocumentReference(this.reference); + + @override + final DocumentReference reference; + + /// A reference to the [DocumentReferenceQueryCollectionReference] containing this document. + DocumentReferenceQueryCollectionReference get parent { + return _$DocumentReferenceQueryCollectionReference(reference.firestore); + } + + @override + Stream snapshots() { + return reference.snapshots().map((snapshot) { + return DocumentReferenceQueryDocumentSnapshot._( + snapshot, + snapshot.data(), + ); + }); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then((snapshot) { + return DocumentReferenceQueryDocumentSnapshot._( + snapshot, + snapshot.data(), + ); + }); + } + + @override + Future delete() { + return reference.delete(); + } + + Future update({ + Object? ref = _sentinel, + }) async { + final json = { + if (ref != _sentinel) + "ref": ref as DocumentReference>, + }; + + return reference.update(json); + } + + Future set(DocumentReferenceQuery value) { + return reference.set(value); + } + + @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); +} + +class DocumentReferenceQueryDocumentSnapshot extends FirestoreDocumentSnapshot { + DocumentReferenceQueryDocumentSnapshot._( + this.snapshot, + this.data, + ); + + @override + final DocumentSnapshot snapshot; + + @override + DocumentReferenceQueryDocumentReference get reference { + return DocumentReferenceQueryDocumentReference( + snapshot.reference, + ); + } + + @override + final DocumentReferenceQuery? data; +} + +abstract class DocumentReferenceQueryQuery + implements QueryReference { + @override + DocumentReferenceQueryQuery limit(int limit); + + @override + DocumentReferenceQueryQuery limitToLast(int limit); + + DocumentReferenceQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }); + DocumentReferenceQueryQuery whereRef({ + DocumentReference>? isEqualTo, + DocumentReference>? isNotEqualTo, + DocumentReference>? isLessThan, + DocumentReference>? isLessThanOrEqualTo, + DocumentReference>? isGreaterThan, + DocumentReference>? isGreaterThanOrEqualTo, + bool? isNull, + List>>? whereIn, + List>>? whereNotIn, + }); + + 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 + implements DocumentReferenceQueryQuery { + _$DocumentReferenceQueryQuery( + this.reference, + this._collection, + ); + + final CollectionReference _collection; + + @override + final Query reference; + + DocumentReferenceQueryQuerySnapshot _decodeSnapshot( + QuerySnapshot snapshot, + ) { + final docs = snapshot.docs.map((e) { + return DocumentReferenceQueryQueryDocumentSnapshot._(e, e.data()); + }).toList(); + + final docChanges = snapshot.docChanges.map((change) { + return FirestoreDocumentChange( + type: change.type, + oldIndex: change.oldIndex, + newIndex: change.newIndex, + doc: DocumentReferenceQueryDocumentSnapshot._( + change.doc, change.doc.data()), + ); + }).toList(); + + return DocumentReferenceQueryQuerySnapshot._( + snapshot, + docs, + docChanges, + ); + } + + @override + Stream snapshots( + [SnapshotOptions? options]) { + return reference.snapshots().map(_decodeSnapshot); + } + + @override + Future get([GetOptions? options]) { + return reference.get(options).then(_decodeSnapshot); + } + + @override + DocumentReferenceQueryQuery limit(int limit) { + return _$DocumentReferenceQueryQuery( + reference.limit(limit), + _collection, + ); + } + + @override + DocumentReferenceQueryQuery limitToLast(int limit) { + return _$DocumentReferenceQueryQuery( + reference.limitToLast(limit), + _collection, + ); + } + + DocumentReferenceQueryQuery whereDocumentId({ + String? isEqualTo, + String? isNotEqualTo, + String? isLessThan, + String? isLessThanOrEqualTo, + String? isGreaterThan, + String? isGreaterThanOrEqualTo, + bool? isNull, + List? whereIn, + List? whereNotIn, + }) { + return _$DocumentReferenceQueryQuery( + reference.where( + FieldPath.documentId, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + _collection, + ); + } + + DocumentReferenceQueryQuery whereRef({ + DocumentReference>? isEqualTo, + DocumentReference>? isNotEqualTo, + DocumentReference>? isLessThan, + DocumentReference>? isLessThanOrEqualTo, + DocumentReference>? isGreaterThan, + DocumentReference>? isGreaterThanOrEqualTo, + bool? isNull, + List>>? whereIn, + List>>? whereNotIn, + }) { + return _$DocumentReferenceQueryQuery( + reference.where( + _$DocumentReferenceQueryFieldMap["ref"]!, + isEqualTo: isEqualTo, + isNotEqualTo: isNotEqualTo, + isLessThan: isLessThan, + isLessThanOrEqualTo: isLessThanOrEqualTo, + isGreaterThan: isGreaterThan, + isGreaterThanOrEqualTo: isGreaterThanOrEqualTo, + isNull: isNull, + whereIn: whereIn, + whereNotIn: whereNotIn, + ), + _collection, + ); + } + + 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, + }) { + var query = reference.orderBy(FieldPath.documentId, descending: descending); + + if (startAtDocument != null) { + query = query.startAtDocument(startAtDocument.snapshot); + } + if (startAfterDocument != null) { + query = query.startAfterDocument(startAfterDocument.snapshot); + } + if (endAtDocument != null) { + query = query.endAtDocument(endAtDocument.snapshot); + } + if (endBeforeDocument != null) { + query = query.endBeforeDocument(endBeforeDocument.snapshot); + } + + if (startAt != _sentinel) { + query = query.startAt([startAt]); + } + if (startAfter != _sentinel) { + query = query.startAfter([startAfter]); + } + if (endAt != _sentinel) { + query = query.endAt([endAt]); + } + if (endBefore != _sentinel) { + query = query.endBefore([endBefore]); + } + + return _$DocumentReferenceQueryQuery(query, _collection); + } + + 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, + }) { + var query = reference.orderBy(_$DocumentReferenceQueryFieldMap["ref"]!, + descending: descending); + + if (startAtDocument != null) { + query = query.startAtDocument(startAtDocument.snapshot); + } + if (startAfterDocument != null) { + query = query.startAfterDocument(startAfterDocument.snapshot); + } + if (endAtDocument != null) { + query = query.endAtDocument(endAtDocument.snapshot); + } + if (endBeforeDocument != null) { + query = query.endBeforeDocument(endBeforeDocument.snapshot); + } + + if (startAt != _sentinel) { + query = query.startAt([startAt]); + } + if (startAfter != _sentinel) { + query = query.startAfter([startAfter]); + } + if (endAt != _sentinel) { + query = query.endAt([endAt]); + } + if (endBefore != _sentinel) { + query = query.endBefore([endBefore]); + } + + return _$DocumentReferenceQueryQuery(query, _collection); + } + + @override + bool operator ==(Object other) { + return other is _$DocumentReferenceQueryQuery && + other.runtimeType == runtimeType && + other.reference == reference; + } + + @override + int get hashCode => Object.hash(runtimeType, reference); +} + +class DocumentReferenceQueryQuerySnapshot extends FirestoreQuerySnapshot< + DocumentReferenceQueryQueryDocumentSnapshot> { + DocumentReferenceQueryQuerySnapshot._( + this.snapshot, + this.docs, + this.docChanges, + ); + + final QuerySnapshot snapshot; + + @override + final List docs; + + @override + final List> + docChanges; +} + +class DocumentReferenceQueryQueryDocumentSnapshot + extends FirestoreQueryDocumentSnapshot + implements DocumentReferenceQueryDocumentSnapshot { + DocumentReferenceQueryQueryDocumentSnapshot._(this.snapshot, this.data); + + @override + final QueryDocumentSnapshot snapshot; + + @override + DocumentReferenceQueryDocumentReference get reference { + return DocumentReferenceQueryDocumentReference(snapshot.reference); + } + + @override + final DocumentReferenceQuery data; +} + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +DateTimeQuery _$DateTimeQueryFromJson(Map json) => + DateTimeQuery( + const FirestoreDateTimeConverter().fromJson(json['time'] as Timestamp), + ); + +const _$DateTimeQueryFieldMap = { + 'time': 'time', +}; + +Map _$DateTimeQueryToJson(DateTimeQuery instance) => + { + 'time': const FirestoreDateTimeConverter().toJson(instance.time), + }; + +TimestampQuery _$TimestampQueryFromJson(Map json) => + TimestampQuery( + const FirestoreTimestampConverter().fromJson(json['time'] as Timestamp), + ); + +const _$TimestampQueryFieldMap = { + 'time': 'time', +}; + +Map _$TimestampQueryToJson(TimestampQuery instance) => + { + 'time': const FirestoreTimestampConverter().toJson(instance.time), + }; + +GeoPointQuery _$GeoPointQueryFromJson(Map json) => + GeoPointQuery( + const FirestoreGeoPointConverter().fromJson(json['point'] as GeoPoint), + ); + +const _$GeoPointQueryFieldMap = { + 'point': 'point', +}; + +Map _$GeoPointQueryToJson(GeoPointQuery instance) => + { + 'point': const FirestoreGeoPointConverter().toJson(instance.point), + }; + +DocumentReferenceQuery _$DocumentReferenceQueryFromJson( + Map json) => + DocumentReferenceQuery( + const FirestoreDocumentReferenceConverter() + .fromJson(json['ref'] as DocumentReference>), + ); + +const _$DocumentReferenceQueryFieldMap = { + 'ref': 'ref', +}; + +Map _$DocumentReferenceQueryToJson( + DocumentReferenceQuery instance) => + { + 'ref': const FirestoreDocumentReferenceConverter().toJson(instance.ref), + }; diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/movie.g.dart b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/movie.g.dart index 5f1033b2f12a..dd58c13998ca 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/movie.g.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/lib/movie.g.dart @@ -1,5 +1,7 @@ // GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + part of 'movie.dart'; // ************************************************************************** diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/example/test_driver/query_reference_test.dart b/packages/cloud_firestore_odm/cloud_firestore_odm/example/test_driver/query_reference_test.dart index 29b430774605..a43899c29ecd 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/example/test_driver/query_reference_test.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/example/test_driver/query_reference_test.dart @@ -3,10 +3,13 @@ // 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/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 'common.dart'; + void main() { group('QueryReference', () { late FirebaseFirestore customFirestore; @@ -84,5 +87,86 @@ void main() { ); }); }); + + test('supports DateTimes', () async { + final ref = await initializeTest(dateTimeQueryRef); + + await ref.add(DateTimeQuery(DateTime(1990))); + await ref.add(DateTimeQuery(DateTime(2000))); + await ref.add(DateTimeQuery(DateTime(2010))); + + final snapshot = await ref.orderByTime(startAt: DateTime(2000)).get(); + + expect(snapshot.docs.length, 2); + + expect(snapshot.docs[0].data.time, DateTime(2000)); + expect(snapshot.docs[1].data.time, DateTime(2010)); + }); + + test('supports Timestamp', () async { + final ref = await initializeTest(timestampQueryRef); + + await ref.add(TimestampQuery(Timestamp.fromDate(DateTime(1990)))); + 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(); + + expect(snapshot.docs.length, 2); + + expect(snapshot.docs[0].data.time, Timestamp.fromDate(DateTime(2000))); + expect(snapshot.docs[1].data.time, Timestamp.fromDate(DateTime(2010))); + }); + + test('supports GeoPoint', () async { + final ref = await initializeTest(geoPointQueryRef); + + await ref.add(GeoPointQuery(const GeoPoint(19, 0))); + 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(); + + expect(snapshot.docs.length, 2); + + expect(snapshot.docs[0].data.point, const GeoPoint(20, 0)); + expect(snapshot.docs[1].data.point, const GeoPoint(20, 0)); + }); + + test( + 'supports DocumentReference', + () 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')), + ); + + 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'), + ); + }, + skip: 'Blocked by FlutterFire support for querying document references', + ); }); } diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/lib/cloud_firestore_odm.dart b/packages/cloud_firestore_odm/cloud_firestore_odm/lib/cloud_firestore_odm.dart index 2148a0db4b4b..0546ef41af5c 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/lib/cloud_firestore_odm.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/lib/cloud_firestore_odm.dart @@ -1,3 +1,6 @@ +import 'package:cloud_firestore/cloud_firestore.dart'; +import 'package:json_annotation/json_annotation.dart'; + export 'annotation.dart'; export 'src/firestore_builder.dart' show FirestoreBuilder; export 'src/firestore_reference.dart' @@ -11,3 +14,71 @@ export 'src/firestore_reference.dart' FirestoreQuerySnapshot, FirestoreReference, QueryReference; + +/// The list of all [JsonConverter]s that cloud_firestore_odm offers. +/// +/// This list is meant to be passed to [JsonSerializable] as followed: +/// +/// ```dart +/// @JsonSerializable(converters: firestoreJsonConverters) +/// ``` +const firestoreJsonConverters = [ + FirestoreDateTimeConverter(), + FirestoreTimestampConverter(), + FirestoreGeoPointConverter(), +]; + +/// A [JsonConverter] that adds support for [Timestamp] objects within ODM models. +class FirestoreTimestampConverter extends JsonConverter { + const FirestoreTimestampConverter(); + @override + Timestamp fromJson(Timestamp json) => json; + + @override + Timestamp toJson(Timestamp object) => object; +} + +/// A [JsonConverter] that adds support for [GeoPoint] objects within ODM models. +class FirestoreGeoPointConverter extends JsonConverter { + const FirestoreGeoPointConverter(); + @override + GeoPoint fromJson(GeoPoint json) => json; + + @override + GeoPoint toJson(GeoPoint object) => object; +} + +/// A [JsonConverter] that adds support for [DateTime] objects within ODM models. +class FirestoreDateTimeConverter extends JsonConverter { + const FirestoreDateTimeConverter(); + @override + DateTime fromJson(Timestamp json) => json.toDate(); + + @override + Timestamp toJson(DateTime object) => Timestamp.fromDate(object); +} + +/// A [JsonConverter] that adds support for [DocumentReference] objects within +/// ODM models. +/// +/// The document reference must receive a `Map` as generic +/// argument. References coming from `withConverter` are not supported. +class FirestoreDocumentReferenceConverter extends JsonConverter< + DocumentReference>, + DocumentReference>> { + const FirestoreDocumentReferenceConverter(); + + @override + DocumentReference> fromJson( + DocumentReference> json, + ) { + return json; + } + + @override + DocumentReference> toJson( + DocumentReference> object, + ) { + return object; + } +} diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm/pubspec.yaml b/packages/cloud_firestore_odm/cloud_firestore_odm/pubspec.yaml index 6c7ec754ead0..3ef8d80ffd77 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm/pubspec.yaml +++ b/packages/cloud_firestore_odm/cloud_firestore_odm/pubspec.yaml @@ -14,6 +14,7 @@ dependencies: cloud_firestore: ^3.2.1 flutter: sdk: flutter + json_annotation: ^4.5.0 meta: ^1.3.0 dev_dependencies: diff --git a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_generator.dart b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_generator.dart index 8cf978400ac0..6af16788e66f 100644 --- a/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_generator.dart +++ b/packages/cloud_firestore_odm/cloud_firestore_odm_generator/lib/src/collection_generator.dart @@ -99,6 +99,16 @@ class Data { } } +const _dateTimeChecker = TypeChecker.fromRuntime(DateTime); + +const _timestampChecker = TypeChecker.fromUrl( + 'package:cloud_firestore_platform_interface/src/timestamp.dart#Timestamp', +); + +const _geoPointChecker = TypeChecker.fromUrl( + 'package:cloud_firestore_platform_interface/src/geo_point.dart#GeoPoint', +); + @immutable class CollectionGenerator extends ParserGenerator { final _collectionTemplates = >[ @@ -319,7 +329,11 @@ class CollectionGenerator extends ParserGenerator { f.type.isDartCoreInt || f.type.isDartCoreDouble || f.type.isDartCoreBool || - f.type.isPrimitiveList, + f.type.isPrimitiveList || + f.type.isJsonDocumentReference || + _dateTimeChecker.isAssignableFromType(f.type) || + _timestampChecker.isAssignableFromType(f.type) || + _geoPointChecker.isAssignableFromType(f.type), // TODO filter list other than LIst ) .where((f) => !f.isJsonIgnored()) @@ -382,6 +396,14 @@ extension on String { } extension on DartType { + bool get isJsonDocumentReference { + return element?.librarySource?.uri.scheme == 'package' && + const {'cloud_firestore'} + .contains(element?.librarySource?.uri.pathSegments.first) && + element?.name == 'DocumentReference' && + (this as InterfaceType).typeArguments.single.isDartCoreMap; + } + bool get isPrimitiveList { if (!isDartCoreList) return false; diff --git a/packages/cloud_firestore_odm/doc/defining-models.md b/packages/cloud_firestore_odm/doc/defining-models.md index b528d33dd771..310bb9455259 100644 --- a/packages/cloud_firestore_odm/doc/defining-models.md +++ b/packages/cloud_firestore_odm/doc/defining-models.md @@ -17,7 +17,15 @@ import 'package:cloud_firestore_odm/cloud_firestore_odm.dart'; // This doesn't exist yet...! See "Next Steps" part 'user.g.dart'; -@JsonSerializable(explicitToJson: true) +/// A custom JsonSerializable annotation that supports decoding objects such +/// as Timestamps and DateTimes. +/// This variable can be reused between different models +const firestoreSerializable = JsonSerializable( + explicitToJson: true, + converters: firestoreJsonConverters, +); + +@firestoreSerializable class User { User({ required this.name, @@ -33,11 +41,12 @@ class User { The `User` model defines that a user must have a name and email as a `String` and age as an `int`. +:::caution If your model class is defined in a separate file than the Firestore reference, you will need to explicitly specify `fromJson`/`toJson` functions as followed: ```dart -@JsonSerializable(explicitToJson: true) +@firestoreSerializable class User { User({ required this.name, @@ -55,6 +64,8 @@ class User { } ``` +::: + **Note**: `JsonSerializable(fieldRename: ...)` and `JsonKey(ignore: true)` are currently not supported ## Model validation @@ -68,7 +79,7 @@ The ODM provides some basic annotation validators which can be used on model pro example, we can take advantage of the `Min` validator: ```dart -@JsonSerializable(explicitToJson: true) +@firestoreSerializable class User { User({ required this.name, @@ -102,7 +113,7 @@ method. Note the name of this class is generated based on the model name (for ex The following annotations are available for `int` properties: | Annotation | Description | -|------------|----------------------------------------------------| +| ---------- | -------------------------------------------------- | | `Min` | Validates a number is not less than this value. | | `Max` | Validates a number is not greater than this value. | @@ -129,7 +140,7 @@ class EmailAddressValidator implements Validator { Within the model, you can then apply the validator to the property: ```dart -@JsonSerializable(explicitToJson: true) +@firestoreSerializable class User { User({ required this.name, @@ -158,7 +169,7 @@ within the Firestore database. For example, the `users` collection in the root o corresponds to the `Users` model we defined previously: ```dart -@JsonSerializable(explicitToJson: true) +@firestoreSerializable class User { // ... } diff --git a/packages/cloud_firestore_odm/doc/references.md b/packages/cloud_firestore_odm/doc/references.md index eda9e1dbabe8..8a8d30c439df 100644 --- a/packages/cloud_firestore_odm/doc/references.md +++ b/packages/cloud_firestore_odm/doc/references.md @@ -110,7 +110,7 @@ Models define exactly what our data schema is, therefore this allows the ODM to useful type-safe methods for querying. ```dart -@JsonSerializable(explicitToJson: true) +@@firestoreSerializable class User { User({ required this.name, diff --git a/packages/cloud_firestore_odm/doc/subcollections.md b/packages/cloud_firestore_odm/doc/subcollections.md index 35855a0c72b1..8a2938bf8e57 100644 --- a/packages/cloud_firestore_odm/doc/subcollections.md +++ b/packages/cloud_firestore_odm/doc/subcollections.md @@ -6,7 +6,7 @@ The ODM provides support for subcollections via the `Collection` annotation. For the root collection as normal: ```dart -@JsonSerializable(explicitToJson: true) +@firestoreSerializable class User { // ... } @@ -19,7 +19,7 @@ Let's assume each user document contains a subcollection containing user address the model for an address: ```dart -@JsonSerializable(explicitToJson: true) +@firestoreSerializable class Address { // ... }