0
0
Firebasecloud~10 mins

Deleting documents in Firebase - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to delete a document from Firestore.

Firebase
await firestore.collection('users').doc([1]).delete();
Drag options to blanks, or click blank then click option'
AdocId
BuserId
C'userId123'
Ddocument
Attempts:
3 left
💡 Hint
Common Mistakes
Using a variable name without quotes.
Forgetting to call the delete() method.
2fill in blank
medium

Complete the code to delete a document using async/await syntax.

Firebase
async function removeDoc() {
  try {
    await firestore.collection('posts').doc([1]).delete();
  } catch (error) {
    console.error(error);
  }
}
Drag options to blanks, or click blank then click option'
ApostId
B'post123'
CdocRef
DdocumentId
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a variable without quotes.
Not awaiting the delete() call.
3fill in blank
hard

Fix the error in the code to delete a Firestore document.

Firebase
firestore.collection('orders').[1]('orderId123').delete();
Drag options to blanks, or click blank then click option'
Adoc
Bdelete
Cget
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using get() instead of doc().
Calling delete() without a document reference.
4fill in blank
hard

Fill both blanks to delete a document and handle errors properly.

Firebase
firestore.collection('products').[1]([2]).delete().catch(error => console.error(error));
Drag options to blanks, or click blank then click option'
Adoc
B'prod456'
Cget
D'productId'
Attempts:
3 left
💡 Hint
Common Mistakes
Using get() instead of doc().
Passing a variable without quotes as document ID.
5fill in blank
hard

Fill all three blanks to delete a document inside an async function with error handling.

Firebase
async function deleteUser() {
  try {
    await firestore.collection([1]).doc([2]).[3]();
  } catch (error) {
    console.error(error);
  }
}
Drag options to blanks, or click blank then click option'
A'users'
B'user789'
Cdelete
Dremove
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove() instead of delete().
Not using quotes around collection or document IDs.