Bird
0
0

What is wrong with this Firestore document reference?

medium📝 Debug Q7 of 15
GCP - Cloud Firestore and Bigtable
What is wrong with this Firestore document reference?
const docRef = db.doc('users');
AMissing document ID in path
BCollection name should be 'user' not 'users'
Cdoc() cannot be called on db directly
DNo error, this is valid
Step-by-Step Solution
Solution:
  1. Step 1: Understand doc() path requirements

    doc() requires a full path including collection and document ID.
  2. Step 2: Analyze given path

    'users' is a collection name only, missing document ID after slash.
  3. Final Answer:

    Missing document ID in path -> Option A
  4. Quick Check:

    doc() needs collection/document path [OK]
Quick Trick: doc() path must include document ID after collection [OK]
Common Mistakes:
  • Using only collection name in doc()
  • Confusing collection and document
  • Assuming doc() can be called on db directly

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes