What would be the most efficient way to check for a value of a field in Firestore collection? Suppose there are multiple documents in organizations table, I want to loop through every 'orgcode' field in documents, and see if at least 1 matches.
public static boolean isCodeValidationSuccessful(String _code){
Log.i(TAG, "code validation reached");
mDb = FirebaseFirestore.getInstance();
mDb.collection("organizations")
.whereEqualTo("orgcode", _code).get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if(!task.isSuccessful()) {
mIsSuccessful = true;
Log.i(TAG, "passcode successful, task: " + task.getResult());
}
else{
mIsSuccessful = false;
}
}
});
return mIsSuccessful;
}