0
0
Firebasecloud~10 mins

Creating collections and documents in Firebase - Interactive Practice

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

Complete the code to create a new collection named 'users'.

Firebase
const usersCollection = firestore.collection('[1]');
Drag options to blanks, or click blank then click option'
Adata
Bdocuments
Citems
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong collection name like 'documents' or 'data'.
2fill in blank
medium

Complete the code to add a new document with ID 'user123' to the 'users' collection.

Firebase
firestore.collection('users').doc('[1]').set({ name: 'Alice' });
Drag options to blanks, or click blank then click option'
AuserId
Buser123
CdocId
D123user
Attempts:
3 left
💡 Hint
Common Mistakes
Using a generic ID like 'userId' or a wrong ID like '123user'.
3fill in blank
hard

Fix the error in the code to correctly add a document with auto-generated ID.

Firebase
firestore.collection('users').[1]({ name: 'Bob' });
Drag options to blanks, or click blank then click option'
Aadd
Bset
Cdoc
Dcreate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' without specifying a document ID causes an error.
4fill in blank
hard

Fill both blanks to create a document reference and set data in it.

Firebase
const docRef = firestore.collection('[1]').doc('[2]');
docRef.set({ age: 30 });
Drag options to blanks, or click blank then click option'
Aemployees
Bemp001
Cusers
Duser001
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing collection and document names or using wrong IDs.
5fill in blank
hard

Fill all three blanks to create a nested collection and add a document with data.

Firebase
const docRef = firestore.collection('[1]').doc('[2]').collection('[3]');
docRef.add({ status: 'active' });
Drag options to blanks, or click blank then click option'
Aprojects
BprojA
Ctasks
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong collection or document names or mixing levels.