Flutter Firestore Query Nested Subcollections

前端 未结 1 1939
谎友^
谎友^ 2021-01-24 02:59

I am trying to query subcollection in Firebase, but I always get an empty list...

This is my query:

Firestore.instance.collection(\'messages\').where(\'i         


        
相关标签:
1条回答
  • 2021-01-24 03:43

    Since Firstore queries are always shallow, you have to build the path to the subcollection to query.

    Firestore.instance
        .collection('messages')
        .document(...)   // ID of the nested document
        .collection(...).  // ID of the nested subcollection
        .where('idFrom', isEqualTo: userID);
    

    There is no way to avoid giving those nested IDs. If you can't identify the full path of the subcollection to query, you won't be able to access its documents.

    0 讨论(0)
提交回复
热议问题