開始使用 Firestore (Datastore 模式) API

本頁提供了一個小練習題,練習如何透過 Firestore in Datastore mode API 來建立 TaskList 指令列應用程式。TaskList 應用程式用於存放、列出、更新及移除工作。

必要條件

  1. 能夠以本主題所使用的程式語言來撰寫並執行指令列應用程式
    在繼續本教學課程之前,除了對應用程式開發應有基本瞭解之外,也應知道如何下載與安裝額外的程式庫。
  2. 已啟用 Datastore mode API 的專案
    使用 Datastore 模式的應用程式會與已啟用 Datastore mode API 的 Google Cloud 專案相關聯。 Google Cloud 這個專案會以您在應用程式中所使用的憑證,以便 Google 辨識應用程式,並驗證專案使用 Datastore 模式 API 的權限。
    請按照這些操作說明建立專案,為專案啟用 Datastore 模式 API,並使用 gcloud auth login 指令設定本機開發環境的驗證憑證。記下專案 ID,後續步驟將會用到。

安裝和設定

為您的開發環境配置所需的設定及安裝程式庫。

C#

  1. 確認已安裝 Visual Studio (2013 或更新的版本 )。
  2. 範例存放區下載 TaskList 範例應用程式。
  3. 將下載下來的檔案解壓縮在「Documents」(文件) 目錄下。
  4. 在 Visual Studio 中開啟 dotnet-docs-samples-master\datastore\api\Datastore.sln 檔案。
  5. 在 Visual Studio 的「方案總管」視窗中,按一下「TaskList」專案滑鼠右鍵,然後選擇「設定為啟動專案」
  6. 再次以滑鼠右鍵按一下「TaskList」專案,然後選擇「Properties」
  7. 在「Properties」(屬性) 視窗中,按一下「Debug」(偵錯),並在「Command line arguments:」(指令列引數:) 方塊中輸入您的Google Cloud 專案 ID。

    Visual Studio Debug Window

  8. 按一下 [File] (檔案) 接著點選 [Save] (儲存) 儲存您所做的變更。

  9. 執行應用程式,按下鍵盤上的 F5

Go

  1. 複製一份 TaskList 應用程式範例。

    go get github.com/GoogleCloudPlatform/golang-samples/datastore/tasks
    
  2. 將路徑變更至您所複製範例的目錄:

    cd $GOPATH/src/github.com/GoogleCloudPlatform/golang-samples