Complete the code to delete a document from Firestore.
await firestore.collection('users').doc([1]).delete();
To delete a document, you need to specify its exact ID as a string inside doc().
Complete the code to delete a document using async/await syntax.
async function removeDoc() {
try {
await firestore.collection('posts').doc([1]).delete();
} catch (error) {
console.error(error);
}
}The document ID must be a string literal inside doc() to delete the correct document.
Fix the error in the code to delete a Firestore document.
firestore.collection('orders').[1]('orderId123').delete();
get() instead of doc().delete() without a document reference.The doc() method is used to specify the document reference before calling delete().
Fill both blanks to delete a document and handle errors properly.
firestore.collection('products').[1]([2]).delete().catch(error => console.error(error));
get() instead of doc().Use doc() with the exact document ID string to delete the document and catch errors.
Fill all three blanks to delete a document inside an async function with error handling.
async function deleteUser() {
try {
await firestore.collection([1]).doc([2]).[3]();
} catch (error) {
console.error(error);
}
}remove() instead of delete().Use the collection name as a string, the document ID as a string, and call the delete() method to remove the document.