Is there the ability with Firebase Firestore to only get one field from a document?
public String getUserName(){
DocumentReference docRef = db.collection("cities").document(mAuth.getUid());
docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
@Override
public void onComplete(@NonNull Task<DocumentSnapshot> task) {
if (task.isSuccessful()) {
DocumentSnapshot document = task.getResult();
if (document != null) {
Log.d(TAG, "DocumentSnapshot data: " + task.getResult().getData());
} else {
Log.d(TAG, "No such document");
}
} else {
Log.d(TAG, "get failed with ", task.getException());
}
}
});
return name;
}
I use the above code to retrieve a Map with all data in it but would like to know if there is functionality to just call a field name and retrieve that fields data?
My Firestore database is below. I would like to be able to retrieve the Name field only.