Skip to content

Commit 109d7c7

Browse files
authored
Merge pull request #1 from ComposeFlow/firestore_page
Firestore page
2 parents 58a59d1 + 7a2f70d commit 109d7c7

9 files changed

+93
-0
lines changed

public/image/firestore_actions.png

101 KB
Loading
60.1 KB
Loading
98.5 KB
Loading
124 KB
Loading
98.4 KB
Loading
74.4 KB
Loading
56.4 KB
Loading
85.4 KB
Loading
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
title: Firestore
3+
description: Explains how to integrate Firebase Firestore
4+
sidebar:
5+
order: 2
6+
---
7+
8+
import { Steps } from '@astrojs/starlight/components';
9+
10+
# Firestore Integration in ComposeFlow
11+
12+
Firestore integration in ComposeFlow allows you to seamlessly manage and interact with your Firestore database within your ComposeFlow projects. This guide will walk you through setting up and using Firestore in ComposeFlow.
13+
14+
---
15+
16+
:::note
17+
### Prerequisites
18+
19+
Before you begin, ensure that Firebase integration is properly configured for your project. For detailed instructions, refer to the [Firebase Setup Guide](/firebase/setup).
20+
:::
21+
22+
---
23+
24+
## Using Firestore in ComposeFlow
25+
26+
### 1. Associating a Data Type with a Firestore Collection
27+
28+
<Steps>
29+
1. Navigate to the **Firestore** section in the top-level navigation of ComposeFlow. This is your entry point for managing Firestore collections and their associations with data types.
30+
31+
2. **Tap the "Associate a Data Type" Button**
32+
This button allows you to associate a Firestore collection with a specific data type in ComposeFlow.
33+
![Firestore association button](/image/firestore_associate_button.png)
34+
35+
3. **Fill in the Association Details**
36+
- **Firestore Collection Name**: Enter the name of the Firestore collection you want to link.
37+
- **Data Type**: Choose an existing data type from your project or create a new one to represent the entities stored in the Firestore collection.
38+
See [Data type](/guides/data_type) for more details about Data type.
39+
![Firestore association dialog](/image/firestore_associate_dialog.png)
40+
41+
4. **Save the Association**
42+
Once saved, ComposeFlow will recognize the documents in the Firestore collection as a list of entities of the specified data type.
43+
44+
5. **Edit Data Type Fields (Optional)**
45+
You can customize the fields of the associated data type by editing them in the right-hand pane after creating the association.
46+
![Firestore data type](/image/firestore_data_type.png)
47+
</Steps>
48+
49+
---
50+
51+
### 2. What Happens After Association
52+
53+
Once you associate a Firestore collection with a data type, two key features become available:
54+
55+
#### A. "Firestore" Actions
56+
57+
- **Visibility**:
58+
The set of Firestore related actions such as "Save to Firestore" becomes visible in the list of available actions.
59+
60+
![Firestore actions](/image/firestore_actions.png)
61+
62+
- **Usage**:
63+
You can save an entity to the associated Firestore collection by invoking this action.
64+
65+
![Save to firestore action](/image/save_to_firestore_action.png)
66+
67+
#### B. Firestore Collection as a State
68+
69+
- **Visibility**:
70+
The associated Firestore collection is now accessible as part of the ComposeFlow states.
71+
![Firestore collection as state](/image/firestore_collection_as_state.png)
72+
73+
- **Usage**:
74+
Assign the Firestore collection state to any value to query and retrieve the entities stored in the collection.
75+
![Firestore collection as state assigned](/image/firestore_collection_as_state_assigned.png)
76+
77+
---
78+
79+
## Example Workflow
80+
81+
1. Navigate to **Firestore** and associate the `ToDo` collection with a data type `Todo`.
82+
2. Customize the `ToDo` data type to include fields like `name`, `done`.
83+
3. Use the "Save to Firestore" action to add new ToDo item to the Firestore collection.
84+
4. Query the `ToDo` collection by assigning its state as dynamic items in the `LazyColumn`.
85+
5. After running the app, you can observe invoking the "Save to Firestore" action or adding a document from the Firestore console directly is instantly reflected in the running app
86+
87+
---
88+
89+
## Key takeaways
90+
91+
- Firestore integration in ComposeFlow simplifies the management of Firestore collections by directly linking them with structured data types.
92+
- Changes to data types or actions are instantly reflected in your project, ensuring consistency with your Firestore database.
93+

0 commit comments

Comments
 (0)