javascript - How to check and see if a child node in Firebase has data in it -


my plan check see if child node called '1' has data in it. , if does, when user types name , presses 'submit', create new node called '2' them.

$(document).on('click', '#enter', getname);  function getname() {     var name = $('#user').val().trim();      if(database.ref('players').child(1).exists())     {         database.ref('players').child(2).update({             name: name,             choice: '',             losses: '',             wins: ''         });     }     database.ref('players').child(1).update({         name: name,         choice: '',         losses: '',         wins: ''     }); } 


Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

arrays - Algorithm to find ideal starting spot in a circle -