我正在使用firestore where()方法来测试嵌套字段与另一个值的相等性 . 嵌套字段位于文档结构中:公寓/公寓/地址/ locality_short
以下是我目前正在进行的操作(在下面的代码中),但它没有返回任何文档://导入导入来自'angularfire2 / firestore';
//注入构造函数(私有afs:AngularFirestore){}
//根据是否//apartment.property.address.locality_short == search_object.locality_short检索公寓的方法
search(search_obj:Search):Observable {return this.afs.collection('/Apartments',ref => ref.where( property,address,locality_short
,'==','search_obj.Address.locality_short')) . valueChanges()}
1 回答
解决了!在尝试了表达嵌套fieldPath的不同方法之后,结果发现使用点“ . ”分离嵌套级别工作正常,我的另一个错误是将where()方法中的值表示为字符串而不是实际值 . 所以下面的代码工作并返回基于嵌套fieldPath的评估结果与angularfirestore的where()方法中的值的结果
search(search_obj:Search):Observable {return this.afs.collection('/Apartments',ref => ref .where(
property.address.locality_short
,'==',search_obj.Address.locality_short)) . valueChanges()}