Return key just added in firebase


I have 2 tables and I'm using firebase realtime database.

One is tournaments, the other is teams. Teams have a tournament id, tournaments have a list of team ids.

When I add a new team with the right tournament id, I want to take that new team id and add it to the list of team_ids within the tournament object. However, I can't find a way to get the key of the team object that has just been added.

How do I get the key of the object just added via a firebase query? If I was writing this myself it would be given on the response.

Hey pkme! If you open the left panel of the editor and look at the firebase realtime db query's properties there, do you see the id returned as part of the property there? It looks like that will return the same object that was appended or updated. Hope this helps!

No, this does not appear there. I am using the firebase function of "append to list" so the key is not known until the object is created on the server.

Hey pkme,
 If the key for the new object isn't returned by Firebase after an "append to list" action, the best way to find the key would be to then query the db for the item in particular to retrieve it. Retool passes on the entire response from Firebase, and if the key isn't present in the response, there is no way to receive it at that time.