Bird
0
0

Which of the following is the correct way to reference a document named profile123 in a collection users using Firestore SDK?

easy📝 Syntax Q3 of 15
GCP - Cloud Firestore and Bigtable
Which of the following is the correct way to reference a document named profile123 in a collection users using Firestore SDK?
Adb.collection('profile123').doc('users')
Bdb.collection('users/profile123')
Cdb.collection('users').doc('profile123')
Ddb.users.profile123
Step-by-Step Solution
Solution:
  1. Step 1: Understand Firestore document referencing

    To get a document, first get the collection, then the document by ID.
  2. Step 2: Check syntax correctness

    db.collection('users').doc('profile123') uses collection() then doc() correctly; db.collection('users/profile123') is invalid because collection() expects a collection path; db.collection('profile123').doc('users') reverses names; db.users.profile123 is invalid syntax.
  3. Final Answer:

    db.collection('users').doc('profile123') -> Option C
  4. Quick Check:

    Correct document reference = db.collection('users').doc('profile123') [OK]
Quick Trick: Use collection() then doc() to reference documents [OK]
Common Mistakes:
  • Swapping collection and document names
  • Using dot notation incorrectly
  • Using invalid method chaining

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes