-
Notifications
You must be signed in to change notification settings - Fork 172
Description
Thank you for this awesome package!
I have been raking my brain for weeks trying to figure out how to set a custom key when pushing new data to the firebase real time database.
I was trying to do this to push the data, while hoping to use the UID as the key:
await firebase.Child("ContactUs").Child(UID)
.PostAsync<ContactusModel>(new ContactusModel()
{ FirstName = contactus.FirstName, LastName = contactus.LastName, PhoneNumber = contactus.PhoneNumber, Email = contactus.Email, Description = contactus.Description, MainIssue = contactus.MainIssue });
return true;
However, as you notice, it was adding another child with ID inside my UID:
I tried to search far and wide but the API's in the Google Firebase docs for Real time database are different than this package and several functions meant to do this aren't available. Close to giving up I decided to try PutAsync instead of PushAsync like this:
await firebase.Child("ContactUs").Child(UID)
.PutAsync<ContactusModel>(new ContactusModel()
{ FirstName = contactus.FirstName, LastName = contactus.LastName, PhoneNumber = contactus.PhoneNumber, Email = contactus.Email, Description = contactus.Description, MainIssue = contactus.MainIssue });
return true;
Miraculously it seems to have fixed the issue of the extra child, but I have no clue why. I also checked the docs and the source code to see what's going on but I have no clue.

Does any one have an explanation for this behavior? And is it possible use PostAsync instead of PutAsync since Put is supposed to be meant for updating and not creating a new item?
