问题
I'm using Firebase Realtime Database integrated in a mobile app and web panel. By default, a unique ID on Realtime DB is generated on this format: -Lup7ey2xRPO9Owm67xM
When creating new register through the Firebase panel, i can customize the unique id with GUID.
{
"0a921e40-5959-43bc-b2be-a65f6712288d": {
"name": "Test"
},
}
However, after call Rest API, with Postman or on my backend, the unique ID is generated by default on Firebase:
{
"-LupIEooOPXAzbc--dB_": {
"name": "Test 2"
},
}
Is it a possible configure Firebase do generate unique ids on format GUID? Replacing default format?
回答1:
The documentation for the REST API says that using POST is the equivalent of a push operation, which always generates that random push ID. If you want to specify your own name for the node to add, you should be using a PUT request instead and using the client-generated ID in the path for the update.
来源:https://stackoverflow.com/questions/59098699/customize-ids-into-firebase-realtime-database