If you know how the CollectionReference
of the sub-collection, you can easily get the parent DocumentReference
with parent
property of the CollectionReference
. From the DocumentReference
you just need to use the id
property.
You didn't share much details on your data model, so it is difficult to give more guidance on how to find the CollectionReference
. Mark's answer presents some possible approaches.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…