【发布时间】:2019-05-27 05:42:56
【问题描述】:
我的代码有问题,我不知道如何以正确的方式解决它。
我正在尝试编写一个过滤器,当用户点击每个过滤器时,它会自动从 firestore 查询数据。
在我的 Redux Saga 中有这个:
const {type, currency, location} = action.payload;
一切正常,但问题是当我尝试使用动态输入查询数据时: 例如:
firebase
.firestore()
.collection("ItemData")
.where("type", "==", type)
.where('currency', '==', currency)
.where('location', '==', location)
当用户单击选项type 时,它什么都不显示,因为输入currency 和location 没有数据,只有空字符串,因此查询不返回任何响应。除非您单击所有过滤器,否则它将显示正确的响应。
那么我该如何解决这个问题呢?
【问题讨论】:
标签: javascript reactjs firebase google-cloud-firestore