firebase realtime database delete data code example

Example 1: firestore javascript delete document

// define document location (Collection Name > Document Name > Collection Name >)
var docRef = Firebase.firestore().collection("Rooms").doc("bsYNIwEkjP237Ela6fUp").collection("Messages");

// delete the document
docRef.doc("lKjNIwEkjP537Ela6fhJ").delete();

Example 2: javascript write to firebase

function writeUserData(userId, name, email, imageUrl) {
  firebase.database().ref('users/' + userId).set({
    username: name,
    email: email,
    profile_picture : imageUrl
  });
}

Example 3: firebase update data

await firebase.database().ref().update(updates);

Tags: