Firestore where clause doesn't make the condition.

前端 未结 2 1374
醉酒成梦
醉酒成梦 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: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
        })
      })
    }
    

提交回复
热议问题