Omar Dadabhoy
Omar Dadabhoy

Reputation: 59

How to prevent firebase database from creating multiple IDs when using the childByAutoId metod

I am new to databases and started using the firebase database when I found the childByAutoId function to be useful as it randomly generates an Id code for me. However I have not find a way to prevent duplicate IDs when randomly generating. Is this automatically integrated in method? or is up to me to prevent duplicate Ids from being added into the database and how would do something like this. Thank you.

Upvotes: 0

Views: 585

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317760

The chance of it generating a duplicate is astronomically low. You generally just assume that never generates a dup. This blog explains in more detail.

https://firebase.googleblog.com/2015/02/the-2120-ways-to-ensure-unique_68.html

Upvotes: 1

Related Questions