简体   繁体   中英

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>.

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

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 .

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)

As you can see, you are limited to 1 MiB total of data in a single document. 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.

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