Bird
0
0

Why might this Firestore document update fail? docRef.update({"location.city": "Boston"})

medium📝 Debug Q7 of 15
GCP - Cloud Firestore and Bigtable
Why might this Firestore document update fail? docRef.update({"location.city": "Boston"})
ABecause dot notation cannot be used to update nested fields
BBecause Firestore only supports flat documents
CBecause the update method requires an array
DBecause the document does not exist
Step-by-Step Solution
Solution:
  1. Step 1: Understand dot notation in updates

    Firestore supports dot notation to update nested fields like "location.city".
  2. Step 2: Identify common failure cause

    If the document does not exist, update will fail because it cannot modify a non-existent document.
  3. Final Answer:

    Because the document does not exist -> Option D
  4. Quick Check:

    Update fails if document missing, dot notation allowed [OK]
Quick Trick: Ensure document exists before updating nested fields [OK]
Common Mistakes:
  • Thinking dot notation is invalid
  • Assuming update needs arrays
  • Believing Firestore disallows nested fields

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes