Firestore query criteria
Console.log of the query result
Source code-render data
I am new to react native firebase firestore.
I am designing an app where the functionality is that the user should be able to search for a registered user on any of the three critieria:
by Name
by Expertise
by Location
If the user explicitly types in these fields, my code will retrieve the filtered result from firestore
Code in react native to retrieve from firestore:
var db = firebase.firestore();
var routeRef = db.collection("users");
var queryResult = routeRef
.where(("Name", "==", NameInput)
.where("Expertise", "==", ExpertiseInput)
.where("Location","==" , LocationInput))
.get().then(function(snapshot){/* ... */}
Scenario: If the user did not type in any search criteria in the UI for any one field, say "Location" , in that scenario I dont want to set the filter for that criteria from firestore. That means , the expected code should be:
var queryResult = routeRef
.where(("Name", "==", NameInput)
.where("Expertise", "==", ExpertiseInput)
Question: I am not sure how to dynamically set the .where condition based on the whether user typed in UI or not. Can anyone please help?
Still this does not get the query result