Firestore
Firestore Integration in ComposeFlow
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.
Using Firestore in ComposeFlow
1. Associating a Data Type with a Firestore Collection
-
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.
-
Tap the “Associate a Data Type” Button This button allows you to associate a Firestore collection with a specific data type in ComposeFlow.
-
Fill in the Association Details
- Firestore Collection Name: Enter the name of the Firestore collection you want to link.
- Data Type: Choose an existing data type from your project or create a new one to represent the entities stored in the Firestore collection.
See Data type for more details about Data type.
-
Save the Association Once saved, ComposeFlow will recognize the documents in the Firestore collection as a list of entities of the specified data type.
-
Edit Data Type Fields (Optional) You can customize the fields of the associated data type by editing them in the right-hand pane after creating the association.
2. What Happens After Association
Once you associate a Firestore collection with a data type, two key features become available:
A. “Firestore” Actions
- Visibility: The set of Firestore related actions such as “Save to Firestore” becomes visible in the list of available actions.
- Usage: You can save an entity to the associated Firestore collection by invoking this action.
B. Firestore Collection as a State
-
Visibility: The associated Firestore collection is now accessible as part of the ComposeFlow states.
-
Usage: Assign the Firestore collection state to any value to query and retrieve the entities stored in the collection.
Example Workflow
- Navigate to Firestore and associate the
ToDo
collection with a data typeTodo
. - Customize the
ToDo
data type to include fields likename
,done
. - Use the “Save to Firestore” action to add new ToDo item to the Firestore collection.
- Query the
ToDo
collection by assigning its state as dynamic items in theLazyColumn
. - 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
Key takeaways
- Firestore integration in ComposeFlow simplifies the management of Firestore collections by directly linking them with structured data types.
- Changes to data types or actions are instantly reflected in your project, ensuring consistency with your Firestore database.