0
0
GCPcloud~10 mins

Firestore collections and documents 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 get a reference to the Firestore collection named 'users'.

GCP
const usersCollection = firestore.collection('[1]');
Drag options to blanks, or click blank then click option'
Ausers
Bdocuments
Cdata
Ditems
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'documents' instead of the collection name.
Using 'data' or 'items' which are not collection names.
2fill in blank
medium

Complete the code to get a reference to a document with ID 'user123' inside the 'users' collection.

GCP
const userDoc = firestore.collection('users').[1]('user123');
Drag options to blanks, or click blank then click option'
Adoc
Bget
Cadd
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using get() instead of doc() to get a document reference.
Using add() which creates a new document with a random ID.
3fill in blank
hard

Fix the error in the code to add a new document with data to the 'orders' collection.

GCP
firestore.collection('orders').[1]({ item: 'book', quantity: 3 });
Drag options to blanks, or click blank then click option'
Adoc
Badd
Cset
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using set() directly on a collection which causes an error.
Using get() which only reads data.
4fill in blank
hard

Fill both blanks to update the 'status' field to 'shipped' in the document with ID 'order456' in the 'orders' collection.

GCP
firestore.collection('[1]').[2]('order456').update({ status: 'shipped' });
Drag options to blanks, or click blank then click option'
Aorders
Busers
Cdoc
Dcollection
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'users' instead of 'orders' for the collection.
Using collection() instead of doc() to get a document reference.
5fill in blank
hard

Fill all three blanks to delete the document with ID 'session789' from the 'sessions' collection.

GCP
firestore.[1]('[2]').[3]('session789').delete();
Drag options to blanks, or click blank then click option'
Acollection
Bdoc
Csessions
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using get() instead of doc() to get the document reference.
Swapping collection name and method calls.