Firestore where clause doesn't make the condition.

前端 未结 2 1375
醉酒成梦
醉酒成梦 2021-01-24 00:30

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.

相关标签:
2条回答
  • 2021-01-24 01:10

    try making an index at firebase for your query since without the index it will fail to bring out your result. You can get the link to make the index at the console in an error so check your console

    0 讨论(0)
  • 2021-01-24 01:24

    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
        })
      })
    }
    
    0 讨论(0)
提交回复
热议问题