Firestore Document Model
📖 Scenario: You are building a simple app to store user profiles in Google Firestore. Each user has a unique ID, a name, and an email address. You want to create the Firestore document model to represent these users.
🎯 Goal: Create a Firestore document model by defining a dictionary that represents a user profile, add a configuration for the collection name, write the code to add the user document to Firestore, and complete the Firestore client initialization.
📋 What You'll Learn
Create a dictionary called
user_profile with keys id, name, and email and exact values "user123", "Alice Smith", and "alice@example.com" respectively.Create a variable called
collection_name and set it to "users".Write code to add the
user_profile dictionary as a document to the Firestore collection named collection_name using the id as the document ID.Initialize the Firestore client by importing the necessary module and creating a client instance called
db.💡 Why This Matters
🌍 Real World
Firestore is a popular NoSQL database used in many cloud applications to store and sync data in real time. Modeling documents correctly is essential for efficient data storage and retrieval.
💼 Career
Understanding Firestore document models and how to interact with Firestore using client libraries is a key skill for cloud developers and engineers working with Google Cloud Platform.
Progress0 / 4 steps