0

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?

user3681
  • 75
  • 1
  • 7

1 Answers1

1

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.

Alex Mamo
  • 112,184
  • 14
  • 139
  • 167