I\'m using Firebase Cloud Firestore
, I want when I\'m getting a document with reference field inside to receive the reference field as a document and not as a r
You can get multiple documents from a collection. Read get mutiple documents section from documentation
Here's an example
db.collection("classes")
.document(idOfTheClassYouWantToGet)
.collection("users")
.get()
.addOnCompleteListener(new OnCompleteListener<QuerySnapshot>(){
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (DocumentSnapshot document : task.getResult()) {
User user = document.toObject(Users.class);
}
}
}
});
You can't instruct the Firestore client SDK to automatically follow document references during a fetch of a single document. You have to request each individual document. In other words, there is no "join" operation like you might expect in SQL.
See also: What is firestore Reference data type good for?