7
votes

When using push() Firebase creates a unique ID or key such as -KKm9iRSax-scGn7m3Lb.

According to the docs:

The push() method generates a unique ID every time a new child is added to the specified Firebase reference.

And:

The unique ID generated by push() is based on a timestamp, so list items are automatically ordered chronologically.

Is this ID or key unique to the whole database or only to the reference (like /users)?

1

1 Answers

11
votes

Firebase keys are part timestamp and part random characters. So while they should be unique across the whole database there is a small chance that two keys could end up being the same.

Firebase blog: The 2^120 Ways to Ensure Unique Identifiers