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

php - How to display all orders for a single product showing the most recent first? Woocommerce -

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

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -