Adding Documents in Firebase: Using add() vs set()
📖 Scenario: You are building a simple app to store user profiles in Firebase Firestore. You want to learn how to add new user documents to a collection using two different methods: add() and set().This will help you understand how to create documents with automatic IDs and how to create or overwrite documents with specific IDs.
🎯 Goal: Build a Firebase Firestore setup where you first create a collection called users and add user documents using add() and set() methods correctly.
📋 What You'll Learn
Create a Firestore collection reference called
usersRef pointing to the users collectionAdd a new user document with automatic ID using
add() with exact dataCreate a user document with a specific ID using
set() with exact dataUse correct Firestore syntax for both methods
💡 Why This Matters
🌍 Real World
Adding and managing user data in Firestore is common in apps like social networks, e-commerce, and content management systems.
💼 Career
Understanding Firestore document creation methods is essential for cloud developers working with Firebase backend services.
Progress0 / 4 steps