0
0
GCPcloud~10 mins

Why NoSQL on GCP matters - Test Your Understanding

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

Complete the code to access a Firestore collection using the GCP client.

GCP
gcp_client = firestore.Client()
db = gcp_client.[1]('users')
Drag options to blanks, or click blank then click option'
Acollection
Bcreate_instance
Cdelete_instance
Dupdate_instance
Attempts:
3 left
💡 Hint
Common Mistakes
Using methods that create or delete instances instead of accessing collections.
2fill in blank
medium

Complete the code to add a document to a Firestore collection.

GCP
doc_ref = db.[1]('users').document('user1')
doc_ref.set({'name': 'Alice', 'age': 30})
Drag options to blanks, or click blank then click option'
Aget
Bupdate
Cdelete
Dcollection
Attempts:
3 left
💡 Hint
Common Mistakes
Using get or delete which do not create collections.
3fill in blank
hard

Fix the error in the Firestore query to retrieve documents where age is greater than 25.

GCP
query = db.collection('users').where('age', '[1]', 25)
Drag options to blanks, or click blank then click option'
A=
B<
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' or '<' which filter for equality or less than, not greater than.
4fill in blank
hard

Fill both blanks to create a Firestore document update that changes the user's age and adds a new field.

GCP
doc_ref.update({'[1]': 31, '[2]': 'active'})
Drag options to blanks, or click blank then click option'
Aage
Bstatus
Cname
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Using fields unrelated to the update like 'email' or 'name'.
5fill in blank
hard

Fill all three blanks to create a Firestore query that orders users by age descending and limits results to 5.

GCP
query = db.collection('[1]').order_by('[2]', direction='[3]').limit(5)
Drag options to blanks, or click blank then click option'
Ausers
Bage
CDESCENDING
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Ordering by 'name' or using ascending direction.