0

How do you use multiple conditionals on queries on the firestore database when using reactjs. I have the code for a single conditional but not multiple. I have found the documentation poor when using firestore with reactjs.

Single Conditional:

const qSnap = await getDocs(query(collectedInfoRef, where("email", "==", sendFields['user_email'])));

1 Answer 1

1

query can take multiple arguments. Just add a comma, and then your next condition, and repeat if necessary

const qSnap = await getDocs(
  query(
    collectedInfoRef,
    where("email", "==", sendFields["user_email"]),
    where("foo", "==", "bar"),
    limit(3),
  )
);

Note that for some queries, you may need to create an index for it to work. If you try to run a query that needs an index, check your dev console and you'll see a message which has a link that you can follow to create the index

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

Comments

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.