0
0
Firebasecloud~5 mins

Creating collections and documents in Firebase - Quick Revision & Summary

Choose your learning style9 modes available
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?
ACreate a new database
BGet a reference to a collection
CWrite data directly without reference
DDelete an existing document
Which method automatically generates a document ID when adding data?
Aset()
Bupdate()
Cadd()
Dget()
Can you create a document without specifying a collection in Firestore?
ANo, documents must be inside collections
BOnly for subcollections
COnly if you use the admin SDK
DYes, documents can exist alone
What does set() do if the document ID already exists?
AOverwrites the existing document data
BDeletes the document
CCreates a new document with a different ID
DThrows an error
Which of these is true about Firestore collections?
ACollections can contain other collections directly
BCollections are the same as documents
CDocuments can contain other documents
DCollections contain documents, which 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.