re-base icon indicating copy to clipboard operation
re-base copied to clipboard

Include immediatelyAvailableReference.key in push?

Open nicksantan opened this issue 5 years ago • 1 comments

Hi there,

In my app users are allowed to write refs but not update them. Unfortunately, I need a child's uuid key stored as a property on that ref, so I'd like to include it with 'push'. I've been using 'push' and then updating the property with an update call, but that's no longer an option. Is there a way to include the uuid/key as a property in a single push method? Thanks for your help -

nicksantan avatar Oct 08 '19 21:10 nicksantan

For reference, this is the type of strategy I'm trying to deploy (standard Firebase code):

  var myRef = firebase.database().ref().push();
  var key = myRef.key();

  var newData={
      id: key,
      Website_Name: this.web_name.value,
      Username: this.username.value,
      Password : this.password.value,
      website_link : this.web_link.value
   }

   myRef.push(newData);

}```

nicksantan avatar Oct 08 '19 21:10 nicksantan