0
0
Firebasecloud~10 mins

Realtime Database vs Firestore decision 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 initialize a Firestore database instance.

Firebase
const db = firebase.firestore().[1]();
Drag options to blanks, or click blank then click option'
Asettings
Bdoc
Cget
Dcollection
Attempts:
3 left
💡 Hint
Common Mistakes
Using collection() or doc() instead of settings() to configure Firestore.
2fill in blank
medium

Complete the code to listen for realtime updates in Realtime Database.

Firebase
database.ref('messages').[1](snapshot => { console.log(snapshot.val()); });
Drag options to blanks, or click blank then click option'
Aonce
Bget
Con
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using once() which only fetches data once instead of listening continuously.
3fill in blank
hard

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

Firebase
db.collection('users').where('age', '[1]', 18).get().then(snapshot => { /* handle data */ });
Drag options to blanks, or click blank then click option'
A>
B==
C<=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '==' which only matches exact age 18.
Using '<=' or '<' which filter younger users.
4fill in blank
hard

Fill both blanks to write a Firestore query that orders users by name and limits to 5 results.

Firebase
db.collection('users').[1]('name').[2](5).get();
Drag options to blanks, or click blank then click option'
AorderBy
Blimit
Cwhere
DstartAt
Attempts:
3 left
💡 Hint
Common Mistakes
Using where instead of orderBy for sorting.
Using startAt instead of limit to restrict results.
5fill in blank
hard

Fill all three blanks to write Realtime Database code that updates user age, sets a listener, and removes a user.

Firebase
database.ref('users/[1]').[2]({ age: 30 });
database.ref('users').[3](snapshot => { console.log(snapshot.val()); });
database.ref('users/[1]').remove();
Drag options to blanks, or click blank then click option'
Auser123
Bupdate
Con
Dset
Attempts:
3 left
💡 Hint
Common Mistakes
Using set() instead of update() which overwrites data.
Using once() instead of on() for listening.