JavaScript Accessing Firebase push() child

I'm slowly getting into Firebase but have what is probably a stupid question. If I am adding children to a reference using push(), how do I retrieve/delete them if I don't save the generated push ID?

For example, take this root:

var ref = https://myaccount.firebaseio.com/player

And if I write a new entry to /player:

var new_player= ref.push({
    name:"User",
    country:"United States"
  })

Firebase generates a push ID for that:

https://myaccount.firebaseio.com/player/-JxgQCQsSLU0dQuwX0j-

which contains the information I pushed. Now lets say I want to retrieve or remove that player? Should I store the generated ID as a child of itself using .key() and .set()?:

//this will get -JxgQCQsSLU0dQuwX0j-
var _newPlayerKey = new_player.key(); 


//updates the record I just created
var update_player = ref.set({
    name:"User",
    country:"United States",
    ref: _newPlayerKey
  })

I don't see how else to access that object by it's generated ID... is there a better way to set this up?

Answer:1

I am trying to plot a GeoJSON LineString on Google Maps using Google Maps API. I am getting the GeoJSON object as an AJAX response and am using "map.data.addGeoJson(data)" function to load the ...

I am trying to plot a GeoJSON LineString on Google Maps using Google Maps API. I am getting the GeoJSON object as an AJAX response and am using "map.data.addGeoJson(data)" function to load the ...

  1. google maps incorrect location
  2. google maps incorrect address
  3. google maps incorrect directions
  4. google maps incorrect postcode
  5. google maps incorrect road name
  6. google maps incorrect current location
  7. google maps incorrect
  8. google maps incorrect route
  9. google maps incorrect street name
  10. google maps incorrect business location
  11. google maps incorrect location iphone
  12. google maps incorrect my location
  13. google maps incorrect my business
  14. google maps report incorrect address
  15. google maps showing incorrect location
  16. google maps timeline incorrect
  17. google maps report incorrect route
  18. google maps showing incorrect current location
  19. google maps showing incorrect time
  20. google maps report incorrect location

I recently asked this question Since then I have discovered that what I wanted to do wont work. This is because the table is generated by a for loop, with their id incrementing each time. As such, ...

I recently asked this question Since then I have discovered that what I wanted to do wont work. This is because the table is generated by a for loop, with their id incrementing each time. As such, ...

Here is my Angular app var filterData = angular.module('myApp',[]).controller('CallWebApi', function($scope, $http) { // Local version of the data $http.get('./events.js'). success(...

Here is my Angular app var filterData = angular.module('myApp',[]).controller('CallWebApi', function($scope, $http) { // Local version of the data $http.get('./events.js'). success(...

  1. convert this date into roman numerals
  2. convert date
  3. convert date sql
  4. convert date to string
  5. convert date to timestamp
  6. convert date to string sql
  7. convert date sql server
  8. convert date format in sql
  9. convert date to text excel
  10. convert date to roman numerals
  11. convert date to string javascript
  12. convert date to string java
  13. convert date to localdate
  14. convert date to milliseconds
  15. convert date to month in excel
  16. convert date to string python
  17. convert date sql server dd/mm/yyyy
  18. convert date format in excel
  19. convert date to timestamp javascript
  20. convert date to string php

Just wondering, is it possible to use only Javascript to hide/show elements without using "style" method? So I won't have to use any inline CSS in my HTML element. Or even, how does jQuery perform the ...

Just wondering, is it possible to use only Javascript to hide/show elements without using "style" method? So I won't have to use any inline CSS in my HTML element. Or even, how does jQuery perform the ...

  1. hide show elements javascript
  2. hide/show elements when checkbox is selected
  3. hide show elements jquery
  4. hide show elements css
  5. hide show elements html
  6. show/hide elements depending on screen size
  7. show/hide elements based on selected option
  8. show & hide elements on click
  9. show hide elements react
  10. show hide elements
  11. show hide elements react native
  12. show hide elements in react js
  13. show hide elements revit
  14. show hide elements angular
  15. show hide elements bootstrap
  16. show hide elements angular 4
  17. show hide elements dreamweaver
  18. show hide elements wordpress
  19. show hide elements responsive design
  20. show hide element angularjs