Exploring Cloud Firestore in Datastore Mode

Hands-On Lab

 

Photo of Joseph Lowery

Joseph Lowery

Google Cloud Training Architect II in Content

Length

00:30:00

Difficulty

Beginner

Data comes in all shapes, sizes, and use cases. A relational database service like Cloud SQL isn't always the answer. Cloud Datastore is a NoSQL database service, ideal for semi-structured data that needs to be highly scalable and available. Cloud Firestore is the next generation of Datastore with enhanced features, and in this hands-on lab, you'll see how to build a Firestore NoSQL database in Cloud Datastore mode for the best of both worlds.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Exploring Cloud Firestore in Datastore Mode

In this hands-on lab, we'll see how to build a Firestore NoSQL database in Cloud Datastore mode for the best of both worlds.

How to Log in to Google Lab Accounts

On the lab page, right-click Open GCP Console and select the option to open it in a new private browser window (this option will read differently depending on your browser — e.g., in Chrome, it says "Open Link in Incognito Window"). Then, sign in to Google Cloud Platform using the credentials provided on the lab page.

On the Welcome to your new account screen, review the text, and click Accept. In the "Welcome L.A.!" pop-up once you're signed in, check to agree to the terms of service, choose your country of residence, and click Agree and Continue.

Exploring Cloud Firestore in Datastore Mode

Now, on to the lab!

Enable APIs.

  1. From the main navigation, click APIs and Libraries > Library.
  2. Search for Datastore.
  3. Select the Cloud Datastore API card.
  4. Click Enable.

Create the database.

  1. From the main navigation, click Datastore.
  2. Choose Datastore mode.
  3. Select your closest location.
  4. Click Create Database.

Define entities.

Entity #1

  1. On the Entities page, make sure you're in the Query by Kind tab.
  2. In the Kind field, enter Flights.
  3. Click Create Entity.
  4. For Key identifier, choose Numeric ID (auto-generated).
  5. Add the following properties:
    • Airline
      • Name: Airline
      • Type: String
      • Value: LA Air, check the Index this property box
      • Click Done.
      • Click Add property.
    • Flight Number
      • Name: Flight Number
      • Type: Integer
      • Value: 101, un-check the Index this property box
      • Click Done.
      • Click Add property
    • Arrival
      • Name: Arrival
      • Type: Data and time
      • Value: Current time, check the Index this property box
      • Click Done.
      • Click Add property
    • OnTime
      • Name: OnTime
      • Type: Boolean
      • Value: True, check the Index this property box
      • Click Done.
  6. Click Create.

Entity #2

  1. Click Create Entity.
  2. In the Airline property, click the dropdown arrow to expand it, and enter the following value:
    • Value: LA Air.
    • Click Done.
  3. In the Flight Number property, click the dropdown arrow to expand it, and enter the following value:
    • Value: 102.
    • Click Done.
  4. In the OnTime property, click the dropdown arrow to expand it, and enter the following value:
    • Value: True
    • Click Done.
  5. Click Create.

Entity #3

  1. Click Create Entity.
  2. In the Airline property, click the dropdown arrow to expand it, and enter the following value:
    • Value: LA Air.
    • Click Done.
  3. In the Flight Number property, click the dropdown arrow to expand it, and enter the following value:
    • Value: 103.
    • Click Done.
  4. In the OnTime property, click the dropdown arrow to expand it, and enter the following value:
    • Value: False
    • Click Done.
  5. Click Add Property and use the following values:
    • Name: Note
    • Type: String
    • Value: Re-routed due to weather, un-check the Index this property box
    • Click Done.
  6. Click Create.

Query the data.

  1. Switch to the Query by GQL tab.

  2. In the Query field, enter the following:

    SELECT * FROM Flights
  3. Click Run Query.

  4. In the Query field, enter the following:

    SELECT * FROM Flights WHERE OnTime = false
  5. Click Run Query.

  6. Review results.

Conclusion

Congratulations on completing this hands-on lab!