Firebase 获取具有多个where条件问题的数据
我正在尝试从具有两个Firebase 获取具有多个where条件问题的数据,firebase,google-cloud-firestore,angularfire2,Firebase,Google Cloud Firestore,Angularfire2,我正在尝试从具有两个where条件的集合中获取数据。我面临的问题是,我需要按两次“获取数据”按钮。我不明白为什么 以下是我的功能: async get_data(){ console.log(this.mnth); console.log(this.selected_user_authId); //where condition await this.firestore.collection("complaints",ref => r
where
条件的集合中获取数据。我面临的问题是,我需要按两次“获取数据”按钮。我不明白为什么
以下是我的功能:
async get_data(){
console.log(this.mnth);
console.log(this.selected_user_authId);
//where condition
await this.firestore.collection("complaints",ref => ref
.where("complaint_agent_id", "==", this.selected_user_authId)
.where("complaint_date_month", "==", this.mnth)
.orderBy('ticketid', 'desc')
)
.get()
.subscribe(response => {
console.log("insidesub")
if(!response.docs.length){
console.log("no data available");
return false;
}
this.goalList=[];
for(let item of response.docs){
var data = Object.assign(item.data(), {docid : item.id})
this.goalList.push(data);
}
}
console.log(this.goalList);
)}
我的控制台.log屏幕截图
在我的索引图像中,我单击了console.log中的链接以创建此索引
哪里可能有问题?您是如何将goalList
记录到控制台的?上面的代码不包括如何将结果记录到consoleforgot,以便在endconsole.log(this.goalList)中添加该行
,编辑了问题,您可以尝试更改您的方法,使其不是异步/等待
?我相信这会影响您,因为它正在等待查询返回数据,但它只会在您再次单击时刷新。除此之外,请注意,正如官方所指出的,这种类型的where
和orderBy()
与不同字段的链接可能无法正常工作。