javascript - Read and return a Firebase Database entry that can also be used to update -


i'm trying retrieve record database , use returned update record. when push record database, returns object can use update it.

/* works */ var result = firebase.database().ref('b').push({ name: 'levi' }); result.update({name: 'leeeevi'}); 

is there way can retrieve record using id, returns object can used update record? following:

var response = firebase.database().ref('/b/' + id).once('value'); response.update({name: 'levi'}); 

i user able read database using id of entry. them able make changes record in database.

push() returns new data path reference through can access unique key/id generated. can use same set data it.

to unique key

// unique key generated push() var pushid = pushref.key; var responseref = firebase.database().ref('/b/' + pushid); responseref.update({name: 'levi'}); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -