简体   繁体   中英

How can I store a list of folders and each folder has list of items in Firestore using Flutter

文件夹列表

具有 URL 的文件列表

That's the list of folders on mega and list of videos. Where I planned on storing each video using it's url and later on play the video using video player packages on pub.dev

Firestore is a document db. Document are a dictionary, key value pairs. It's support values like double, int, strings, arrays.

Firestore works in collections, inside the collections there are documents, inside the documents you can have another collection.

Firestore is a scalable NoSQL cloud database which supports flexible and hierarchical data structures. It is used to store data in documents which are organized into collections. The data are stored in key-value pairs and it supports certain data types ie array, boolean, bytes, date and time etc. as mentioned here . So you can not store a list of folders containing videos in Firestore. To know more about Firestore you can refer this document .

Instead I would suggest you to use Cloud Storage for Firebase which is an object storage service. It allows you to store images, audios, videos, or other user-generated content and you can use Google Cloud Storage APIs to access the same files. To know more about Cloud Storage for Firebase you can refer this document .

Cloud Storage for firebase also allows you to organize your data in folders within the Cloud Storage buckets. To know more about folders in Cloud Storage you can refer this document .

You can save your files in Cloud Storage and store the file URL using Firestore .

And for the arrangement of the folders and items, you can use the structure below:

  • A "MonthlyMemberships" collection
    • Invidual "Month1", "Month2"... documents under the collection
      • List of videos under each document

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM