0
0
Firebasecloud~10 mins

Deleting fields 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 field named 'age' from a Firestore document.

Firebase
docRef.update({ 'age': [1] })
Drag options to blanks, or click blank then click option'
Afirebase.firestore.FieldValue.delete()
Bnull
Cundefined
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using null or undefined does not delete the field.
Setting the field to 0 does not remove it.
2fill in blank
medium

Complete the code to delete the 'address' field from a Firestore document using the modular SDK.

Firebase
updateDoc(docRef, { 'address': [1] })
Drag options to blanks, or click blank then click option'
AFieldValue.delete()
Bnull
Cdelete()
DdeleteField()
Attempts:
3 left
💡 Hint
Common Mistakes
Using FieldValue.delete() is from the older namespaced SDK.
Using null does not delete the field.
3fill in blank
hard

Fix the error in the code to delete the 'phone' field from a Firestore document.

Firebase
docRef.update({ phone: [1] })
Drag options to blanks, or click blank then click option'
Afirebase.firestore.FieldValue.delete()
Bundefined
Cnull
Ddelete()
Attempts:
3 left
💡 Hint
Common Mistakes
Using null or undefined does not remove the field.
Using delete() is not a valid method here.
4fill in blank
hard

Fill both blanks to delete the 'email' field using the modular Firestore SDK.

Firebase
import { updateDoc, doc, [1] } from 'firebase/firestore';

await updateDoc(doc(db, 'users', userId), { 'email': [2] });
Drag options to blanks, or click blank then click option'
AdeleteField
BdeleteField()
CFieldValue.delete()
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Importing with parentheses is wrong.
Using FieldValue.delete() is from the older SDK.
Setting the field to null does not delete it.
5fill in blank
hard

Fill all three blanks to delete multiple fields 'city', 'state', and 'zip' in one update call using the modular SDK.

Firebase
import { updateDoc, doc, [1] } from 'firebase/firestore';

await updateDoc(doc(db, 'locations', locationId), {
  'city': [2],
  'state': [3],
  'zip': [3]
});
Drag options to blanks, or click blank then click option'
AdeleteField
BdeleteField()
Cnull
DFieldValue.delete()
Attempts:
3 left
💡 Hint
Common Mistakes
Using null does not delete fields.
Using FieldValue.delete() is from the older SDK.
Not calling deleteField as a function causes errors.