Bird
0
0

If a Firestore document has a field "tags" with value ["cloud", "database"], what will a query filtering documents where "tags" array contains "cloud" return?

medium📝 Predict Output Q5 of 15
GCP - Cloud Firestore and Bigtable
If a Firestore document has a field "tags" with value ["cloud", "database"], what will a query filtering documents where "tags" array contains "cloud" return?
AIt will return documents only if "tags" is a string
BIt will return the document because "cloud" is in the tags array
CIt will return no documents because arrays cannot be queried
DIt will cause a runtime error
Step-by-Step Solution
Solution:
  1. Step 1: Understand array-contains query

    Firestore supports querying array fields to check if they contain a specific value.
  2. Step 2: Check document's tags field

    The document's "tags" array includes "cloud", so it matches the query.
  3. Final Answer:

    It will return the document because "cloud" is in the tags array -> Option B
  4. Quick Check:

    Array contains query matches documents with value in array [OK]
Quick Trick: Use array-contains to find values inside array fields [OK]
Common Mistakes:
  • Believing arrays can't be queried
  • Confusing array with string fields
  • Expecting errors on valid queries

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More GCP Quizzes