4

I have declared a global variable and defined it in the initState() function of the app.

But when later using that variable in the Where clause of the Cloud Firestore query, the query doesn't work:

.where("email", isEqualTo: _userEmail.toString())

Instead, the query works when used with quotes:

.where("email", isEqualTo: "[email protected]")

Firestore.instance.collection('Matrimonial').where("email", isEqualTo: _userEmail.toString()).getDocuments();

Not Working

Firestore.instance.collection('Matrimonial').where("email", isEqualTo: "[email protected]").getDocuments();

Working

3
  • post you setStatemethod Commented May 2, 2019 at 6:27
  • Did you ever find a solution? Commented Sep 11, 2019 at 21:07
  • Dec 2021, seems to still be an issue... Commented Dec 1, 2021 at 11:27

2 Answers 2

1

I found a way of using a varible parameter in the where clause by using vuefire:

watch: {
    userProfile () {
      this.$bind('allUsers', this.$db.collection('users').where('institution', '==', this.userProfile.institution))
    }
  }

This case, as different admins log in and become the currentUser, then they can only see all of the users from their institution.

Sign up to request clarification or add additional context in comments.

Comments

0

Late to respond, but I was searching or an answer to this question, and using string interpolation worked for me:

Firestore.instance.collection('Matrimonial').where("email", isEqualTo: `${_userEmail.toString()}`).getDocuments();

2 Comments

This method doesn't work for me. There is a syntax error on the backtick quotation.
Thanks @KatherineChen -- odd that this worked for me. Where do you see the error?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.