The Code (Cont.): Deletion


userRef.remove( );
Removes the data at this database location. Any data at child locations will also be deleted. The effect of the remove will be visible immediately and the corresponding event 'value' will be triggered. Synchronization of the remove to the Firebase servers will also be started, and the returned Promise will resolve when complete. If provided, the onComplete callback will be called asynchronously after synchronization has finished.

Deleting the DB

  Deleting user #2


<script>
 //
 // Function to get form values
 //
 function getInputVal( input ) {
  return document.getElementById( input ).value;
 }

 //
 // Delete a user (delete is a reserved word).
 //
 function deleteUser( ) {
  var ID = getInputVal( 'ID' );
  var userRef = firebase.database( ).ref( 'users/' + ID );
  userRef.remove( );
  var out  = "User # " + ID + " deleted";
  document.getElementById( 'result' ).innerHTML = out;
  return( false );
 }

 //
 // Delete the database users (delete is a reserved word).
 //
 function deleteDB( ) {
  var userRef = firebase.database( ).ref( 'users/' );
  userRef.remove( );
  var out = "Database users deleted";
  document.getElementById( 'result' ).innerHTML = out;
  return( false );
 }
</script>





      The sales manager was at death’s door    
      (very near death) after his heart attack.