Skip to content Skip to sidebar Skip to footer

Generate 6 Digit Unique Number In Firebase

I want to generate 6 digit unique number in Firbase (unique must) above attendeeCode should be unique on every new attendess entry I am new in firebase and I have searched alot bu

Solution 1:

Create a six digit number that corresponds to the nth entry into attendees. And then keep track of that number elsewhere.

You can find in other questions that Firebase still does not support COUNT or LENGTH queries.

Create a path called /meta-data (arbitrary) and save the number of current attendees:

meta-data: {
    num_of_attendees: "000000"// parse this client side and send back padded string to keep 6 characters
}

Grab the value every time you add an attendee, increment it, and send it back. This keeps you from grabbing a list of all attendees and getting the length client-side.

A new option: Firebase Cloud Functions

This is still in beta, but is having fair success. They provided and example of this functionality here:

functions-sample

Post a Comment for "Generate 6 Digit Unique Number In Firebase"