Working with Firestore Database
Adding user Data to Firestore Database.
Last updated
Was this helpful?
Adding user Data to Firestore Database.
Last updated
Was this helpful?
Before you begin, ensure the following are ready
Firebase Project: Set up your Firebase project in the .
This will serve as the foundation for enabling Firestore in your app.
Authentication: Enable authentication for your app to control access.
For detailed guidance, check out the
You can read more about how to set up Firebase Authentication in Databutton .
You can watch this video to follow the step by step Firestore database integration.
Go to the Firebase Console and select your project.
This is the main control panel for all Firebase services.
Go to "Firestore Database" in the Firebase Console's left sidebar.
This is where you manage your database setup.
If not created, click "Create Database" and select a starting mode.
Select the Firestore location (pick a location close to your users for optimal performance) and Choose between "Test mode" or "Production mode." Starting with "Test" mode is recommended.
Plan Your Data Structure
Firestore is schema-flexible, meaning it doesn’t enforce a fixed structure. Planning your data structure upfront ensures consistency and scalability.
Identify collections and documents you’ll need.
Consider relationships, such as linking Orders
to Customers or Users
Define the Data You Need to Store
Think about the specific data your app will handle and organize it logically.
Example: Business App to Store Customer Details
Collection: Customers
Fields: name
, email
, phone
, signup_date
, last_login
, etc.
Collection (Optional): Orders
Fields: customer_id
, order_date
, order_details
.
Prompt Example:
You can add the following prompt over your active task :
Alternatively, prompt the Agent for Data Structure Suggestions;
Follow-Up Prompt for Security Rules : Use this prompt to request less strict security rules for initial testing.
Agent Output Example:
Copy these rules into the Firebase Console under the Firestore Rules tab.
Hit the Develop & Test button to validate the rules.
After deploying the rules, validate your Firestore setup by testing basic operations:
Testing Access
Confirm that authenticated users can interact with the database as intended.
Test adding a record to a collection
Verify that unauthorized access is restricted as expected.
Prompt Suggestions:
Implementation
Testing
Click the "Test Connection" button to test your Firestore integration.
Updated Master Prompt for Full Integration: