0
0
Firebasecloud~5 mins

Adding documents (add vs set) in Firebase - Quick Revision & Key Differences

Choose your learning style9 modes available
Recall & Review
beginner
What does the add() method do when adding a document in Firebase?
The add() method creates a new document with a unique ID automatically generated by Firebase in a collection.
Click to reveal answer
beginner
How does the set() method differ from add() when adding documents?
set() writes data to a document with a specified ID. It can create or overwrite the document, unlike add() which auto-generates the ID.
Click to reveal answer
beginner
Can you specify a document ID when using add() in Firebase?
No, add() automatically generates a unique document ID. To specify an ID, you must use set() with a document reference.
Click to reveal answer
intermediate
What happens if you use set() on an existing document?
Using set() on an existing document overwrites its data completely unless you use the merge option to keep existing fields.
Click to reveal answer
beginner
When should you prefer add() over set()?
Use add() when you want Firebase to generate a unique ID automatically and you don't need to control the document ID.
Click to reveal answer
Which method automatically generates a unique document ID in Firebase?
Aadd()
Bset()
Cupdate()
Dget()
Which method allows you to specify the document ID when adding data?
Aadd()
Bset()
Cdelete()
Dlisten()
What happens if you use set() on an existing document without merge option?
AIt merges new data with existing data
BIt deletes the document
CIt throws an error
DIt overwrites the entire document
If you want Firebase to handle document IDs automatically, which method should you use?
Aset()
Bget()
Cadd()
Dupdate()
Which method is best when you need to update or create a document with a known ID?
Aset()
Badd()
Cpush()
Dlisten()
Explain the difference between add() and set() methods in Firebase when adding documents.
Think about how document IDs are handled and whether you control them.
You got /4 concepts.
    When would you choose to use add() instead of set() in your Firebase app?
    Consider ease and control over document IDs.
    You got /4 concepts.