简体   繁体   English

如何使用 Flutter 在 Firestore 中存储文件夹列表并且每个文件夹都有项目列表

[英]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.这是 mega 上的文件夹列表和视频列表。 Where I planned on storing each video using it's url and later on play the video using video player packages on pub.dev我计划使用它的 url 存储每个视频,然后使用 pub.dev 上的视频播放器包播放视频

Firestore is a document db. Firestore 是一个文档数据库。 Document are a dictionary, key value pairs.文档是一个字典,键值对。 It's support values like double, int, strings, arrays.它支持双精度、整数、字符串、arrays 等值。

Firestore works in collections, inside the collections there are documents, inside the documents you can have another collection. Firestore在collections工作,collections里面有文档,文档里面可以有另外的收藏。

Firestore is a scalable NoSQL cloud database which supports flexible and hierarchical data structures. Firestore 是一个可扩展的 NoSQL 云数据库,支持灵活的分层数据结构。 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 .它用于将数据存储在组织成 collections 的文档中。数据存储在键值对中,它支持某些数据类型,即数组、boolean、字节、日期和时间等,如此所述。 So you can not store a list of folders containing videos in Firestore.因此,您无法在 Firestore 中存储包含视频的文件夹列表。 To know more about Firestore you can refer this document .要了解有关 Firestore 的更多信息,您可以参考此文档

Instead I would suggest you to use Cloud Storage for Firebase which is an object storage service.相反,我建议您为 Firebase 使用云存储,这是一个 object 存储服务。 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.它允许您存储图像、音频、视频或其他用户生成的内容,并且您可以使用Google Cloud Storage API访问相同的文件。 To know more about Cloud Storage for Firebase you can refer this document .要了解有关 Firebase 的云存储的更多信息,您可以参考此文档

Cloud Storage for firebase also allows you to organize your data in folders within the Cloud Storage buckets. Cloud Storage for firebase 还允许您在 Cloud Storage 存储桶内的文件夹中组织数据。 To know more about folders in Cloud Storage you can refer this document .要了解有关 Cloud Storage 中文件夹的更多信息,您可以参考此文档

You can save your files in Cloud Storage and store the file URL using Firestore .您可以将文件保存在Cloud Storage中,并使用Firestore存储文件 URL。

And for the arrangement of the folders and items, you can use the structure below:对于文件夹和项目的排列,您可以使用以下结构:

  • A "MonthlyMemberships" collection “MonthlyMemberships”集合
    • Invidual "Month1", "Month2"... documents under the collection Invidual "Month1", "Month2"... 集合下的文档
      • List of videos under each document每个文档下的视频列表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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