Can firebase generate an unique ID as we wish?

Like firebase generating uid. Can firebase generate an unique ID as we wish? If it is possible? how to write a code for it in the following order?

For example PRO00013, PRO00014, PRO00015….

I am asking here, because I’m working in a project for online shopping. when a user adds a product to their inventory it needs to assign an id for every product. that is must be in the human readable format. If it is not possible, just tell me no, I can accept that answer.

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
Jason Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Jason
Guest

You can just call .push() to get randomUUID and then ref.child(randomUUID).setValue(object) where the object can contain field ID such as PRO00013. If this doesn’t fit your needs you can just place ref.child(“PRO00013”).setValue(object) and not include field id in this object. Now you want to get id PRO00014 for the next pushed object. This ain’t gonna happen with firebase. But you can get the last ID added in this ref with query on ref.orderByKey().limitToLast(1); Now you have the last added object from this node and you can simply get the key which will be PRO00013. 1. Cast it to String 2.… Read more »