0
0
GCPcloud~10 mins

Firestore document model in GCP - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a Firestore document reference.

GCP
doc_ref = db.collection('users').[1]('user123')
Drag options to blanks, or click blank then click option'
Adocument
Badd
Cget
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' which retrieves data instead of referencing a document.
Using 'add' which adds a new document instead of referencing an existing one.
2fill in blank
medium

Complete the code to add a new document with an auto-generated ID.

GCP
db.collection('orders').[1]({'item': 'book', 'qty': 3})
Drag options to blanks, or click blank then click option'
Aupdate
Bset
Cadd
Ddelete
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' which requires a document reference.
Using 'update' which only modifies existing documents.
3fill in blank
hard

Fix the error in the code to update a document field.

GCP
db.collection('products').doc('prod1').[1]({'price': 20})
Drag options to blanks, or click blank then click option'
Aset
Bupdate
Cadd
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'add' which creates a new document instead of updating.
Using 'set' which overwrites the whole document.
4fill in blank
hard

Fill both blanks to query documents where age is greater than 25.

GCP
results = db.collection('employees').where('age', [1], [2]).get()
Drag options to blanks, or click blank then click option'
A==
B>
C25
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which only matches exact values.
Using '<' which finds ages less than 25.
5fill in blank
hard

Fill all three blanks to create a dictionary of user names and their emails for users older than 30.

GCP
user_emails = {user.[1]: user.[2] for user in users if user.[3] > 30}
Drag options to blanks, or click blank then click option'
Aname
Bemail
Cage
Did
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'id' instead of 'name' for keys.
Filtering by 'email' instead of 'age'.