Google Cloud: Introduction to Datastore

Share At:

Overview

Datastore is a highly scalable NoSQL database for your web and mobile applications.

Datastore automatically handles sharding and replication, providing you with a highly available and durable database that scales automatically to handle your applications’ load. Datastore provides a myriad of capabilities such as ACID transactions, SQL-like queries, indexes, and much more.

This hands-on lab will show you how to store and query data in Google Cloud Datastore using the Google Cloud.

Store data

In left menu on the Console, Storage section, go to Datastore > Entities.

Under the Datastore mode column, click Select Datastore Mode.

Now choose where you’ll create your database. Use the dropdown menu to select a location:

The location applies to both Cloud Datastore and App Engine for your Google Cloud project. 

You cannot change the location after it has been saved.

Click Create database.

Click Create Entity.

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

Type Task for Kind.

Under Properties use the Add property button to add these properties, and click Done after each one:

Your creation page should now look like this:

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 tab.
  2. In the dropdown lists, select doneis 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.

4. Now try a query of doneis a boolean, and that is true then Apply filters. The results do not include the Task entity that you created, because its done value is not true.

Run GQL queries

  1. Click the Query by GQL tab.
  2. In the query box add the following:
SELECT * FROM Task

Note that Task is case sensitive.

3. Click Run query.

The query results show the Task entity that you created.

Now add a query filter to restrict the results to entities that meet specific criteria:

Run this query:

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.

Output:

Now run this query:

SELECT * FROM Task WHERE done=true

The results do not include the Task entity that you created, because its done value is not true.

Output:

That Concludes Our Tutorial for Google Cloud Datastore.

Happy Learning !!!


Share At:
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Back To Top

Contact Us