我正在使用firestore where()方法来测试嵌套字段与另一个值的相等性。嵌套字段位于文档结构: Apartments/Apartment/property/address/locality_short中。
下面是我目前正在做的事情(在下面的代码中),但是它没有返回任何文档://从‘angularfire2 2/firestore’导入导入{ AngularFirestore};
//注入构造函数(私有afs: AngularFirestore){}
//基于是否//partment.properties ty.address.local_short == search_object.locality_short检索公寓的方法
搜索(search_obj:Search):可观察的{返回this.afs.collection('/Apartments‘),参考=> ref.where(property,address,locality_short,’=‘,this.afs.collection})
发布于 2018-04-29 11:25:08
解决了!在尝试了不同的表示嵌套fieldPath的方法之后,结果是使用点‘’。为了分离嵌套级别,可以正常工作,我的另一个错误是将where()方法中的值表示为字符串而不是实际值。因此,下面的代码工作并返回基于对angularfirestore的where()方法中的值进行嵌套fieldPath计算的结果。
搜索(search_obj:Search):可观察的{返回this.afs.collection('/Apartments',ref => ref .where(property.address.locality_short,‘=’,search_obj.Address.locality_short)) .valueChanges() }
https://stackoverflow.com/questions/50082472
复制相似问题