简体   繁体   English

如何构建 firebase firestore 数据库?

[英]How to structure firebase firestore database?

I am developing a react native( Expo ) travel app in which the admin add all the places and destination category wise my question is how can I add places category wise in Firestore in react native and how to add any data from the dropdown list to firestore>.我正在开发一个 React Native( Expo )旅游应用程序,其中管理员明智地添加所有地点和目的地类别我的问题是如何在 Firestore 中明智地添加地点类别以及如何将下拉列表中的任何数据添加到 Firestore >。

example:-例子:-

place => sate1=> city1 => category: heritage 
                          name:travelplaces1  
          
                 city2 => category:wildlife
                      name:travelplaces2

     state2 => city1 => cetagory:honyemoondestination
                        name:travelplacees1

**image of my app ** **我的应用程序图片**

在此处输入图像描述

I am currently using firebase javascript web SDK version 8 for this expo project我目前正在为此 expo 项目使用 firebase javascript web SDK 版本 8

In my opinion, the simplest structure I can think of would be to store all that data into a single document.在我看来,我能想到的最简单的结构是将所有数据存储到一个文档中。 So you can add all states, all cities, and all categories into separate arrays. That being said, in order to let the admin fill in the form, you'll always have to pay a single document read .因此,您可以将所有州、所有城市和所有类别添加到单独的 arrays 中。话虽这么说,为了让管理员填写表格,您将始终需要支付单个文档 read

However, there are some limits when it comes to how much data you can put into a document.但是,对于可以放入文档的数据量有一些限制。 According to the official documentation regarding usage and limits :根据有关使用和限制的官方文档:

Maximum size for a document: 1 MiB (1,048,576 bytes)文档的最大大小:1 MiB(1,048,576 字节)

As you can see, you are limited to 1 MiB total of data in a single document.如您所见,单个文档中的数据总量不得超过 1 MiB。 When we are talking about storing text, you can store pretty much.当我们谈论存储文本时,您可以存储很多东西。 I doubt you'll reach the limitation but as your arrays get bigger, be careful about this constraint.我怀疑您会达到限制,但随着您的 arrays 变大,请注意此限制。

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

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