0
0
Firebasecloud~10 mins

Document-collection data model 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 get a reference to a collection named 'users'.

Firebase
const usersRef = db.collection('[1]');
Drag options to blanks, or click blank then click option'
Adata
Buser
Cusers
Ddocuments
Attempts:
3 left
💡 Hint
Common Mistakes
Using singular 'user' instead of 'users'.
Using 'documents' or 'data' which are not collection names.
2fill in blank
medium

Complete the code to get a document with ID 'abc123' from the 'users' collection.

Firebase
const docRef = db.collection('users').[1]('abc123');
Drag options to blanks, or click blank then click option'
Adoc
Bget
Ccollection
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'get' which fetches data but does not reference a document.
Using 'collection' which is for collections, not documents.
Using 'add' which creates a new document.
3fill in blank
hard

Fix the error in the code to add a new document to the 'users' collection with data.

Firebase
db.collection('users').[1]({ name: 'Alice', age: 30 });
Drag options to blanks, or click blank then click option'
Aadd
Bdoc
Cset
Dget
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'doc' which only references a document.
Using 'set' which requires a document reference first.
Using 'get' which fetches data.
4fill in blank
hard

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

Firebase
const docRef = db.collection('[1]').[2]('user1');
docRef.set({ active: true });
Drag options to blanks, or click blank then click option'
Ausers
Bdoc
Cposts
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'posts' instead of 'users' for the collection.
Using 'add' instead of 'doc' to get a document reference.
5fill in blank
hard

Fill all three blanks to query documents where 'age' is greater than 25 in 'users' collection.

Firebase
const queryRef = db.collection('[1]').where('[2]', '[3]', 25);
Drag options to blanks, or click blank then click option'
Ausers
Bage
C>
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'name' instead of 'age' as the field.
Using '<' or '=' instead of '>' for the condition.
Using wrong collection name.