Recall & Review
beginner
What is a collection in Firebase Firestore?
A collection is like a folder that holds multiple documents. It organizes data into groups for easy access and management.
Click to reveal answer
beginner
How do you add a new document to a collection in Firebase Firestore?
You use the
add() method on a collection reference to create a new document with an auto-generated ID, or doc().set() to specify the document ID.Click to reveal answer
intermediate
What is the difference between
add() and set() when creating documents?add() creates a document with a random ID inside a collection. set() writes data to a document with a specified ID, creating it if it doesn't exist.Click to reveal answer
beginner
Can a document exist without being inside a collection in Firestore?
No. Every document must be inside a collection. Collections hold documents, and documents can contain subcollections.
Click to reveal answer
intermediate
What happens if you try to create a document with an ID that already exists?
Using
set() will overwrite the existing document data unless you use merge options. Using add() will always create a new document with a unique ID.Click to reveal answer
In Firebase Firestore, what is the first step to add a new document?
✗ Incorrect
You must first get a reference to the collection where you want to add the document.
Which method automatically generates a document ID when adding data?
✗ Incorrect
add() creates a new document with a random unique ID.Can you create a document without specifying a collection in Firestore?
✗ Incorrect
Documents must always be inside collections in Firestore.
What does
set() do if the document ID already exists?✗ Incorrect
set() overwrites the existing document unless merge options are used.Which of these is true about Firestore collections?
✗ Incorrect
Collections hold documents, and documents can have subcollections.
Explain how to create a new document inside a collection in Firebase Firestore.
Think about how folders and files work on your computer.
You got /3 concepts.
Describe the difference between the add() and set() methods when creating documents.
One is like dropping a file in a folder with a random name, the other is like naming the file yourself.
You got /3 concepts.