This page shows you how to store and query data in Cloud Firestore in Datastore mode using the Google Cloud Platform Console.
Before you begin
-
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
-
Select or create a Google Cloud Platform project.
-
If you are not the project owner, your account requires the following permissions to complete this quickstart:
- Your account requires the
Cloud Datastore Owner role
which contains the
datastore.databases.createpermission needed to create a Datastore mode instance. - Datastore mode requires an active App Engine application.
If the project doesn't have an application, this quickstart creates one
for you. In that case, you require the
appengine.applications.createpermission. The project owner can assign this permission with an IAM custom role.
- Your account requires the
Cloud Datastore Owner role
which contains the
Create a database
To create a new database instance, open the Cloud Datastore section
in the Google Cloud Platform Console:
Go to the Cloud Datastore page
Cloud Firestore: Native Mode or Datastore Mode
When you create a new Cloud Firestore database, you have the option to use Cloud Firestore in Native Mode or in Datastore mode.
Select from one of the database options:
-
Cloud Firestore in Native Mode
Use Cloud Firestore in Native mode for mobile and web apps. To get started with Cloud Firestore, continue in the Cloud Firestore Quickstart.
-
Cloud Firestore in Datastore Mode
Use Cloud Firestore in Datastore Mode for new server projects. Select Cloud Firestore in Datastore Mode to use the improved Cloud Firestore storage layer while keeping Datastore mode system behavior.
For more guidance on selecting a database mode and for a feature-by-feature comparison, see choosing between Native Mode and Datastore Mode.
Store data
- Go to the Datastore Entities page in the Google Cloud Platform Console.
Go to the Datastore Entities page
This page allows you to store, query, update, and delete data. - Click Create entity.
If you see the following page, you need to select a location. (Go to the next step if you do not see this page.)
The location applies to both Datastore mode databases and App Engine apps for your Google Cloud Platform project.
To save a location, select one of the location values and click Next.On the Create an entity page, use
[default]for Namespace.Type
Taskfor Kind.Under Properties use the Add property button to add these properties:
Your creation page should now look like this:Name Type Value Indexed description String Learn Google Datastore mode created Date and time (today's date) ✓ done Boolean False ✓
Click Create. The console displays the
Taskentity that you just created.
You just stored data in your database!
Run a query
Datastore mode databases support querying data by kind or by Google Query Language (GQL); the instructions below walk you through the steps of doing both.
Run kind queries
- Click Query by kind.
- Select
Taskas the kind.
The query results show the Task entity that you created.
Next, add a query filter to restrict the results to entities that meet specific criteria:
- Click Filter entities.
- In the dropdown lists, select
done, is a boolean, and that is false. - Click Apply filters. The results show the
Taskentity that you created, since itsdonevalue isfalse.
- Now try a query of
done, is a boolean, and that is true. The results do not include theTaskentity that you created, because itsdonevalue is nottrue.
Run GQL queries
- Click Query by GQL.
- Enter
SELECT * FROM Taskas the query. Note thatTaskis case sensitive. - Click Run query.
The query results show the Task entity that you created.
Again, add a query filter to restrict the results to entities that meet specific criteria:
- Run a query such as
SELECT * FROM Task WHERE done=false. Note thatTaskanddoneare case sensitive. The results show theTaskentity that you created, since itsdonevalue isfalse.
- Now run a query such as
SELECT * FROM Task WHERE done=true. The results do not include theTaskentity that you created, because itsdonevalue is nottrue.
Clean up
- Click Query by kind and ensure
Taskis the selected kind. - Click Clear filters.
- Select the
Taskentity that you created - Click Delete, and then confirm you want to delete the
Taskentity. Once deleted, the entity is permanently removed from your database.
That's it, you completed this quickstart!
What's next
- Learn more about Datastore Queries.
- Learn more about Datastore mode databases.


