Manage Firestore with the console
You can manage Firestore through the following actions in the Google Cloud console:
- View, query, add, edit, and delete data.
- Manage indexes.
View data
You can view all your Firestore data in the Google Cloud console. From the Firestore data viewer, click on a document or collection to open the data nested within that item.
In the Google Cloud console, go to the Databases page.
Select the required database from the list of databases.
In the navigation menu, click Firestore Studio.
Open a specific path
To open a document or collection at a specific path, use the Edit path button
:Non-existent ancestor documents
A document can exist even if one or more its ancestors don't
exist. For example, the document at path
/mycoll/mydoc/mysubcoll/mysubdoc
can exist even if the ancestor document
/mycoll/mydoc
does not. The Firestore data viewer displays
non-existent ancestor documents as follows:
- In a collection's list of documents, the document IDs of non-existent ancestor documents are italicized.
- In a non-existent ancestor document's information panel, the data viewer points out that the document does not exist.
Filter data
You can filter documents in a collection based on field value and the
==
, !-
, >
, >=
, <
, <=
, in
, not-in
, array-contains
,
array-contains-any
conditions. For example, you can display only documents
where the value of field firstname
equals Sam
. To apply a collection filter:
Click the filter button
next to a collection ID:From the Add filters menu, select a document field, a filter condition, and a sort order.
Click Apply.
To remove a collection filter, open the same menu and click Clear filter.
Query data
You can query for documents in the Query Builder tab of the Firestore Studio page.
In the Google Cloud console, go to the Databases page.
Select the required database from the list of databases.
In the navigation menu, click Firestore Studio.
Click the Query Builder tab.
Select a query scope.
Select Collection to query a single collection. In the text field, enter a path to a collection.
Select Collection group to query all collections with the same ID. In the Collection group field, enter a collection group ID.
The table will automatically display documents from the specified collection or collection group.
Click Add to query to filter the returned set of documents. By default, the Query Builder adds a
WHERE
clause. You can modify this clause using the dropdowns and text fields or change to one of the other available clauses. To continue building more complex queries, click Add to query.To remove a query clause, click it's remove button
. To remove all query clauses, click Clear.Click Run to retrieve results from your database.
Query requirements and limitations
As you use the Query Builder, keep in mind the following requirements and limitations for queries.
All queries must be supported by one more indexes. If the database cannot find an index to support the query, it will return an error that contains a link to build the required index.
ORDER BY
clauses must match the fields in theWHERE
clauses and come in the same order. By default, results are ordered by document ID. If you filter by any other field with anything other than an equality (==
), add anORDER BY
clause for that field.Range (
<
,<=
,>
,>=
) and not equals (!=
,not-in
) query clauses must all filter on the same field.
For additional limitations, see Query limitations.
Manage data
In Firestore, you store data in documents and organize your documents into collections. Before you start adding data, learn more about the Firestore data model.
You can add, edit, and delete documents and collections from the Firebase console. To manage your data from the GCP console, go to the Firestore Studio page:
In the Google Cloud console, go to the Databases page.
Select the required database from the list of databases.
In the navigation menu, click Firestore Studio.
Add data
- Click Start Collection.
- Enter a collection ID. Enter a document ID. Firestore will generate document ID, but you can overwrite for a specific document ID. Add fields for the data in your document.
- Click Save. Your new collection and document appear in the data viewer.
- To add more documents to the collection, click Add Document.
Edit data
- Click on a collection to view its documents, then click on a document to view its fields and subcollections.
- Click on a field to edit its value. To add fields or subcollections to the selected document, click Add Field or Start Collection.
Delete data
You can delete documents or collections from the data viewer.
To delete a collection:
- Select the collection you want to delete.
- Click the menu icon at the top of the documents column, then click Delete collection.
To delete a document:
- Select the document you want to delete.
- Click the menu icon at the top of the document details column. Select Delete document or Delete document fields.
Deleting a document deletes all of the nested data in that document, including any subcollections.
Deleting a document's fields does not delete its subcollections. Although empty, the document still exists and can appear in query results.
To delete a specific field in a document:
- Select the document to view its fields.
- Click the delete icon beside the field you want to delete.
Manage Firestore Security Rules
You can view your Firestore Security Rules from the Google Cloud console. To edit or delete your ruleset, enable Firebase, and use the Firebase CLI or Firebase console.
Enabling Firebase
To edit your Firestore Security Rules, you must enable Firebase for your Google Cloud project. If Firebase is not enabled, you can enable Firebase from the Security Rules page:
The Firestore Security Rules feature is closely integrated with Firebase Auth and the Firebase SDKs (Web, Android, Apple platforms). For more on Firebase and Firestore, see getting started with Firebase.
View Security Rules
To view your Firestore Security Rules from the Google Cloud console, go to the Security Rules page:
In the Google Cloud console, go to the Databases page.
Select the required database from the list of databases.
In the navigation menu, click Security Rules.
Edit Security Rules
To edit or delete your Firestore Security Rules, use the Firebase CLI or Firebase console. In the Firebase console, go to the Rules tab in the Firestore section. Learn more about setting up and customizing rules.
Manage indexes
To create new indexes for your queries and manage existing indexes from the Firebase console, go to the Indexes tab in the Firestore section. Learn more about managing indexes.