简体   繁体   中英

most efficient way to organize a json data tree in firebase

what is the most efficient way to organize a json data tree in firebase since I need to post data and then check for repeated data

I am creating a simple email subscription structure

this model?

subscribers
  RandomKeyCode
    email
    created_at

or this one?

subscribers
  emailAsKey
    email <--- repeat email field
    created_at

(It seems to me more readable to use email as a key in this case, and I imagine I can check it more easily when the user tries to enter a repeated email.)

or some other way?

what is the most efficient way to organize a json data tree in firebase

Most efficient way would be to create a database where you can perform your queries very easily. The difference in your examples is the use of a RandomKeyCode vs. emailAsKey . When we are talking about users, the most common approach is to use the uid that is coming from the authentication process but according to the use-case of your app, you can store that data under a random key as well as under the email address. Is your choice whether to use one or the other approach.

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