Firestore in Datastore mode API - Module Google::Cloud (v2.13.1)

Reference documentation and code samples for the Firestore in Datastore mode API module Google::Cloud.

Methods

.datastore

defself.datastore(project_id=nil,credentials=nil,scope:nil,timeout:nil,database_id:nil)->Google::Cloud::Datastore::Dataset
Parameters
  • project_id (String) — Identifier for a Datastore project. If notpresent, the default project for the credentials is used.
  • credentials (Google::Auth::Credentials) — A Google::Auth::Credentialsobject. (SeeDatastore::Credentials)@note Warning: Passing aString to a keyfile path or aHash of credentials is deprecated. Providing an unvalidated credential configuration to Google APIs can compromise the security of your systems and data.

    @example

    # The recommended way to provide credentials is to use themake_creds method # on the appropriate credentials class for your environment.

    credentials = ::Google::Auth::ServiceAccountCredentials.make_creds( json_key_io: ::File.open("/path/to/keyfile.json") )

    datastore = Google::Cloud::Datastore.new( project_id: "my-project-id", credentials: credentials )

  • scope (String, Array<String>)(defaults to: nil)

    The OAuth 2.0 scopes controlling theset of resources and operations that the connection can access. SeeUsing OAuth 2.0 to Access GoogleAPIs.

    The default scope is:

    • https://www.googleapis.com/auth/datastore
  • timeout (Integer)(defaults to: nil) — Default timeout to use in requests. Optional.
Example
require"google/cloud"datastore=Google::Cloud.datastore"my-todo-project","/path/to/keyfile.json"task=datastore.entity"Task","sampleTask"do|t|t["type"]="Personal"t["done"]=falset["priority"]=4t["description"]="Learn Cloud Datastore"enddatastore.savetask

#datastore

defdatastore(scope:nil,timeout:nil,database_id:nil)->Google::Cloud::Datastore::Dataset

Creates a new object for connecting to the Datastore service.Each call creates a new connection.

For more information on connecting to Google Cloud see theAuthentication Guide.

Parameters
  • scope (String, Array<String>)(defaults to: nil)

    The OAuth 2.0 scopes controlling theset of resources and operations that the connection can access. SeeUsing OAuth 2.0 to Access GoogleAPIs.

    The default scope is:

    • https://www.googleapis.com/auth/datastore
  • timeout (Integer)(defaults to: nil) — Default timeout to use in requests. Optional.
Examples
require"google/cloud"gcloud=Google::Cloud.newdatastore=gcloud.datastoretask=datastore.entity"Task"do|t|t["type"]="Personal"t["done"]=falset["priority"]=4t["description"]="Learn Cloud Datastore"enddatastore.savetask

You shouldn't need to override the default scope, but you can:

require"google/cloud"gcloud=Google::Cloud.newplatform_scope="https://www.googleapis.com/auth/cloud-platform"datastore=gcloud.datastorescope:platform_scope

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-11-04 UTC.