@@ -43,6 +43,11 @@ class Field {
4343 /// be enabled on a per-field basis.
4444 final bool enableInfixSearch;
4545
46+ /// Connects a document to a field in another collection.
47+ ///
48+ /// Example value: `ReferencedCollectionName.fieldName` .
49+ final String ? reference;
50+
4651 Field (
4752 this .name, {
4853 this .type,
@@ -54,6 +59,7 @@ class Field {
5459 this .locale,
5560 this .sort = false ,
5661 this .enableInfixSearch = false ,
62+ this .reference,
5763 }) {
5864 if (name.isEmpty) {
5965 throw ArgumentError ('Ensure Field.name is not empty' );
@@ -77,6 +83,7 @@ class Field {
7783 locale: map['locale' ],
7884 sort: map['sort' ] ?? false ,
7985 enableInfixSearch: map['infix' ] ?? false ,
86+ reference: map['reference' ],
8087 );
8188 }
8289
@@ -107,6 +114,9 @@ class Field {
107114 if (enableInfixSearch) {
108115 map['infix' ] = true ;
109116 }
117+ if (reference != null ) {
118+ map['reference' ] = reference;
119+ }
110120 return map;
111121 }
112122
@@ -126,7 +136,8 @@ class Field {
126136 shouldIndex.hashCode ^
127137 locale.hashCode ^
128138 sort.hashCode ^
129- enableInfixSearch.hashCode;
139+ enableInfixSearch.hashCode ^
140+ reference.hashCode;
130141
131142 @override
132143 bool operator == (Object other) {
@@ -141,7 +152,8 @@ class Field {
141152 other.shouldIndex == shouldIndex &&
142153 other.locale == locale &&
143154 other.sort == sort &&
144- other.enableInfixSearch == enableInfixSearch;
155+ other.enableInfixSearch == enableInfixSearch &&
156+ other.reference == reference;
145157 }
146158}
147159
0 commit comments