0
0
Firebasecloud~10 mins

Why advanced patterns solve scale problems in Firebase - Test Your Understanding

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

Complete the code to initialize Firebase in your app.

Firebase
const app = initializeApp({ apiKey: [1] });
Drag options to blanks, or click blank then click option'
A"your-api-key"
Bapikey
Capi_key
DyourApiKey
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the API key
Using incorrect variable names
2fill in blank
medium

Complete the code to get a Firestore collection reference.

Firebase
const colRef = collection(db, [1]);
Drag options to blanks, or click blank then click option'
Adatabase
B"users"
CuserCollection
DcollectionName
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names instead of string literals
Missing quotes around collection name
3fill in blank
hard

Fix the error in the Firestore query to get documents where age is greater than 18.

Firebase
const q = query(colRef, where("age", [1], 18));
Drag options to blanks, or click blank then click option'
A==
B<=
C>
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using equality operator instead of greater than
Using less than or not equal operators
4fill in blank
hard

Fill both blanks to create a batched write that updates two documents.

Firebase
const batch = writeBatch(db);
batch.[1](doc(db, "users", "user1"), { active: false });
batch.[2](doc(db, "users", "user2"), { active: false });
await batch.commit();
Drag options to blanks, or click blank then click option'
Aupdate
Bset
Cdelete
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' which overwrites documents
Using 'delete' which removes documents
5fill in blank
hard

Fill all three blanks to create a Firestore security rule that allows read only if user is authenticated and document owner.

Firebase
allow read: if request.auth != null && request.auth.uid == resource.data.[1] && resource.data.[2] == [3];
Drag options to blanks, or click blank then click option'
AownerId
BuserId
Crequest.auth.uid
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect field names
Comparing to 'true' instead of user ID