Firestore where子句不符合条件。 [英] Firestore where clause doesn't make the condition.

查看:78
本文介绍了Firestore where子句不符合条件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的函数中我有两个where子句。我想要的是检查文件是否退出,找到两个ID。但是当我运行它时,它会返回所有收集记录。任何人都可以告诉我哪里搞砸了?

in my function I have two where clauses. what I want is to check whether a document exits, where two ids are found. but when I run it, it returns all the records of collection. can anybody tell me where I messed up?

setApplyStatus() {
   var query = firebase.firestore().collection('applications')
   query.where("jobSeekerId", '==', this.jobSeekerId).get()
   query.where("jobId", '==', this.job.id)
   query.get().then(querySnapshot => {
    querySnapshot.forEach(doc => {
     console.log(doc.data())
     console.log('already exists')
     this.applyStatus = true
    })
   })
 }


推荐答案

您没有正确链接查询子句。此外,您在链中间调用get()。这几乎肯定不是你想要的。每个查询对象都建立在最后一个,你应该只对链中的最终查询得到():

You're not chaining the query clauses correctly. Also, you're calling get() in the middle of your chain. That's almost certainly not what you want. Each query object builds on the last, and you should only get() on the final query in the chain:

setApplyStatus() {
  var query = firebase.firestore().collection('applications')
    .where("jobSeekerId", '==', this.jobSeekerId)
    .where("jobId", '==', this.job.id)
    .get().then(querySnapshot => {
      querySnapshot.forEach(doc => {
      console.log(doc.data())
      console.log('already exists')
      this.applyStatus = true
    })
  })
}

这篇关于Firestore where子句不符合条件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆