Quickstart

This page shows you how to store and query data in Google Cloud Datastore 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 GCP project.

    Go to the Manage resources page

  • 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.create permission needed to create a Cloud Datastore instance.
    • Cloud Datastore 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.create permission. The project owner can assign this permission with an IAM custom role.

Select 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 or Cloud Datastore

When you create a new Cloud Datastore database, you have the option to use Cloud Datastore or to upgrade to Cloud Firestore. Cloud Firestore is the new version of Cloud Datastore and includes several improvements and new features. Cloud Firestore is a superset of Cloud Datastore, and can run in a backwards-compatible Datastore mode.

Select from one of the database options:

  • Cloud Firestore in Native mode

    If you are comfortable using a product in beta, we encourage you to 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

    If you are comfortable using a product in beta, 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 Cloud Datastore system behavior.

  • Cloud Datastore

    If your app requires a service level agreement (SLA), choose Cloud Datastore.

For more guidance on selecting a database and for a feature-by-feature comparison, see choosing between Cloud Firestore and Cloud Datastore.

Store data

  1. 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.
  2. Click Create entity.
  3. If you see the following page, you need to select a location. (Go to the next step if you do not see this page.)

    Screenshot of the Select a location page

    The location applies to both Cloud Datastore and App Engine for your Google Cloud Platform project.
    To save a location, select one of the location values and click Next.

  4. On the Create an entity page, use [default] for Namespace.

  5. Type Task for Kind.
  6. Under Properties use the Add property button to add these properties:

    Name Type Value Indexed
    description String Learn Google Cloud Datastore
    created Date and time (today's date)
    done Boolean False
    Your creation page should now look like this:

    Screenshot of the entity creation window with properties set

  7. Click Create. The console displays the Task entity that you just created.

You just stored data in Cloud Datastore!

Run a query

Cloud Datastore supports querying data by kind or by Google Query Language (GQL); the instructions below walk you through the steps of doing both.

Run kind queries

  1. Click Query by kind.
  2. Select Task as 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:

  1. Click Filter entities.
  2. In the dropdown lists, select done, is a boolean, and that is false.
  3. Click Apply filters. The results show the Task entity that you created, since its done value is false. Screenshot of a kind query with a filter applied
  4. Now try a query of done, is a boolean, and that is true. The results do not include the Task entity that you created, because its done value is not true.

Run GQL queries

  1. Click Query by GQL.
  2. Enter SELECT * FROM Task as the query. Note that Task is case sensitive.
  3. 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:

  1. Run a query such as SELECT * FROM Task WHERE done=false. Note that Task and done are case sensitive. The results show the Task entity that you created, since its done value is false. Screenshot of a GQL query with a filter applied
  2. Now run a query such as SELECT * FROM Task WHERE done=true. The results do not include the Task entity that you created, because its done value is not true.

Clean up

  1. Click Query by kind and ensure Task is the selected kind.
  2. Click Clear filters.
  3. Select the Task entity that you created
  4. Click Delete, and then confirm you want to delete the Task entity. Once deleted, the entity is permanently removed from Cloud Datastore.

The Task entity that you previously created is deleted from Cloud Datastore.

That's it, you completed this quickstart!

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Datastore Documentation