0
0
Firebasecloud~10 mins

Why Firestore is Firebase's primary database - 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 Firestore in a Firebase app.

Firebase
const db = firebase.[1]();
Drag options to blanks, or click blank then click option'
Astorage
Bauth
Cfirestore
Ddatabase
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'database()' initializes the Realtime Database, not Firestore.
2fill in blank
medium

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

Firebase
db.collection('users').[1]({ name: 'Alice', age: 30 });
Drag options to blanks, or click blank then click option'
Aadd
Bset
Cupdate
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' on a collection causes an error.
3fill in blank
hard

Fix the error in the code to get a document by ID from Firestore.

Firebase
db.collection('users').doc([1]).get().then(doc => { if (doc.exists) { console.log(doc.data()); } });
Drag options to blanks, or click blank then click option'
AdocId
BuserId
Cuser.id
D'userId'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing variable names without quotes when they are not defined.
4fill in blank
hard

Fill both blanks to query Firestore for users older than 25 and order by age.

Firebase
db.collection('users').where('age', [1], 25).[2]('age').get();
Drag options to blanks, or click blank then click option'
A>
BorderBy
C<
Dlimit
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' for filtering older users.
5fill in blank
hard

Fill all three blanks to update a user's email and log success.

Firebase
db.collection('users').doc([1]).[2]({ email: [3] }).then(() => { console.log('Email updated'); });
Drag options to blanks, or click blank then click option'
A'user123'
Bupdate
C'newemail@example.com'
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using set overwrites the whole document.