I have looked at What is Firestore Reference data type good for? but I don't see mentioned anywhere what happens to the reference field/link when the referenced document is deleted because I want to automatically delete the referencing document as well.
So my question is does the reference field become null
or do I have to manually query to check if the referenced doc still exists or not?
I imagine the latter case would involve a lot of read operations.
Here's how I think the former case would be
ref.addSnapshotListener((value, error) -> {
for (QueryDocumentSnapshot queryDocSnap: value){
DocumentReference docRef = queryDocSnap.get("ref");
if (docRef == null){
// delete queryDocSnap
} else{
// do something }
}
});