0
0
Firebasecloud~10 mins

Migrating from Realtime Database to Firestore in Firebase - Interactive Code Practice

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

Complete the code to initialize Firestore in your Firebase project.

Firebase
const db = firebase.[1]();
Drag options to blanks, or click blank then click option'
Afirestore
Bdatabase
Cstorage
Dauth
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'database' instead of 'firestore' will initialize Realtime Database, not Firestore.
Using 'storage' or 'auth' are unrelated services.
2fill in blank
medium

Complete the code to add a new document to a Firestore collection named 'users'.

Firebase
db.collection('users').[1]({ name: 'Alice', age: 30 });
Drag options to blanks, or click blank then click option'
Aget
Bset
Cupdate
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'set' requires a document reference, not a collection.
Using 'update' only modifies existing documents.
Using 'get' retrieves data, not adds it.
3fill in blank
hard

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

Firebase
db.collection('users').where('age', '[1]', 25).get();
Drag options to blanks, or click blank then click option'
A>
B<=
C=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' will only find users exactly 25 years old.
Using '<=' or '!=' will not match the requirement.
4fill in blank
hard

Fill both blanks to update a user's age and merge the data without overwriting the entire document.

Firebase
db.collection('users').doc('user123').[1]({ age: 31 }, { [2]: true });
Drag options to blanks, or click blank then click option'
Aset
Bupdate
Cmerge
Doverwrite
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'update' alone works but does not accept merge options.
Using 'overwrite' is not a Firestore method.
Using 'merge' alone is not a method.
5fill in blank
hard

Fill all three blanks to migrate a Realtime Database listener to Firestore snapshot listener.

Firebase
db.collection('users').[1]((snapshot) => {
  snapshot.docs.forEach(doc => {
    console.log(doc.[2](), doc.[3]);
  });
});
Drag options to blanks, or click blank then click option'
AonSnapshot
Bdata
Cid
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' instead of 'onSnapshot' will not listen for realtime changes.
Accessing document data as a property instead of calling data() causes errors.
Using 'data' as a property instead of a method.