How do I get the Firebase unique id, so I can use it to reference a specific entry?
I am using the push method to store some data, each entry contains a weekNumber and year. I check if a weekNumber already exists, if so I need to update foo and bar. Checking if the weekNumber exists is no problem, but I can't figure out how to update the other fields.
Example data structure:
- ENTRIES
- USER
-JwphpyzzHaNlh8HXA2G
foo: 'string'
bar: 'string'
weekNumber: 32
year: 2015
-Jwphpyzzaasd2H2DHB
foo: 'string'
bar: 'string'
weekNumber: 33
year: 2015
Checking if weekNumber exists:
ref.orderByChild('weekNumber').equalTo(data.weekNumber)
.on('value', function(result) {
});
I tried it with result.key() or result.parent(), but both return the path ENTRIES/USER and not the unique FB key.