Using Flutter Firestore plug in, do something for each sub collection in a document

前端 未结 1 1256
既然无缘
既然无缘 2021-01-28 14:38

To help me better understand Flutter and Firebase, I\'m making a list sharing app. I\'m working on the list home screen that will show a reorderable list tile view with a tile f

1条回答
  •  醉话见心
    2021-01-28 15:25

    There is no method in the Firestore client-side SDKs to get all collections (or subcollections under a specific document). Such API does exist in the server-side SDKs, but not in the client-side SDKs.

    See:

    • Fetching all collections in Firestore
    • How to get all of the collection ids from document on Firestore?

    So you'll need to know the collections already, typically by changing your data model. For example by creating a document for each list's metadata, and then storing the list items in a subcollection with a known name under that document. That way you can get all lists by querying for the documents, which is possible within the API.

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