AngularFirestore的where()方法中如何表示嵌套字段

How to express nested fields in the where() method of AngularFirestore

我正在使用 firestore where() 方法来测试嵌套字段与另一个值的相等性。嵌套字段在文档结构中:Apartments/Apartment/property/address/locality_short

这是我目前的做法(在下面的代码中),但它没有 returning 任何文档: //这里导入 从 'angularfire2/firestore';

导入 {AngularFirestore}

//注入 构造函数(私有 afs:AngularFirestore){}

//根据是否检索公寓的方法 //apartment.property.address.locality_short == search_object.locality_short

搜索(search_obj:搜索):可观察{ return this.afs.collection('/公寓', ref => ref.where(property,address,locality_short, '==', 'search_obj.Address.locality_short')).valueChanges() }

已解决!在尝试了表达嵌套 fieldPath 的不同方式后,结果证明使用点“.”分隔嵌套级别效果很好,我的另一个错误是将我的 where() 方法中的值表示为字符串而不是实际值。因此下面的代码有效,returns 结果基于嵌套的 fieldPath 对 angularfirestore

的 where() 方法中的值的评估

搜索(search_obj:搜索):可观察{ return this.afs.collection('/公寓', ref => ref .where(property.address.locality_short,'==',search_obj.Address.locality_short)) .valueChanges() }