Reference documentation and code samples for the Firestore in Datastore mode API module Google::Cloud::Datastore.
Google Cloud Datastore
Google Cloud Datastore is a fully managed, schemaless database for storing
non-relational data. You should feel at home if you are familiar with
relational databases, but there are some key differences to be aware of to
make the most of using Datastore.
The following Datastore configuration parameters are supported:
project_id - (String) Identifier for a Datastore project. (The
parameter project is considered deprecated, but may also be used.)
credentials - (String, Hash, Google::Auth::Credentials) The path to
the keyfile as a String, the contents of the keyfile as a Hash, or a
Google::Auth::Credentials object. (See Credentials) (The
parameter keyfile is considered deprecated, but may also be used.)
scope - (String, Array
quota_project - (String) The project ID for a project that can be
used by client libraries for quota and billing purposes.
timeout - (Integer) Default timeout to use in requests.
endpoint - (String) Override of the endpoint host name, or nil
to use the default endpoint.
emulator_host - (String) Host name of the emulator. Defaults to
ENV["DATASTORE_EMULATOR_HOST"]
Yields
(Google::Cloud.configure.datastore)
Returns
(Google::Cloud::Config) — The configuration object the
Google::Cloud::Datastore library uses.
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 the
Authentication Guide.
Parameters
project_id (String) (defaults to: nil) — Identifier for a Datastore project. If not
present, the default project for the credentials is used.
credentials (String, Hash, Google::Auth::Credentials) (defaults to: nil) — The path to
the keyfile as a String, the contents of the keyfile as a Hash, or a
Google::Auth::Credentials object. (See Credentials)
scope (String, Array<String>) (defaults to: nil) —
timeout (Integer) (defaults to: nil) — Default timeout to use in requests. Optional.
endpoint (String) (defaults to: nil) — Override of the endpoint host name. Optional.
If the param is nil, uses the default endpoint.
emulator_host (String) (defaults to: nil) — Datastore emulator host. Optional.
If the param is nil, uses the value of the emulator_host config.
database_id (String) (defaults to: nil) — Identifier for a Datastore database in the project. If not
present, the default database of the project will be used.
project (String) (defaults to: nil) — Alias for the project_id argument. Deprecated.
keyfile (String) (defaults to: nil) — Alias for the credentials argument.
Deprecated.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-28 UTC."],[],[],null,["# Firestore in Datastore mode API - Module Google::Cloud::Datastore (v2.13.0)\n\nVersion latestkeyboard_arrow_down\n\n- [2.13.0 (latest)](/ruby/docs/reference/google-cloud-datastore/latest/Google-Cloud-Datastore)\n- [2.12.0](/ruby/docs/reference/google-cloud-datastore/2.12.0/Google-Cloud-Datastore)\n- [2.11.0](/ruby/docs/reference/google-cloud-datastore/2.11.0/Google-Cloud-Datastore)\n- [2.10.0](/ruby/docs/reference/google-cloud-datastore/2.10.0/Google-Cloud-Datastore)\n- [2.9.0](/ruby/docs/reference/google-cloud-datastore/2.9.0/Google-Cloud-Datastore)\n- [2.8.0](/ruby/docs/reference/google-cloud-datastore/2.8.0/Google-Cloud-Datastore)\n- [2.7.1](/ruby/docs/reference/google-cloud-datastore/2.7.1/Google-Cloud-Datastore)\n- [2.6.0](/ruby/docs/reference/google-cloud-datastore/2.6.0/Google-Cloud-Datastore)\n- [2.5.0](/ruby/docs/reference/google-cloud-datastore/2.5.0/Google-Cloud-Datastore)\n- [2.4.0](/ruby/docs/reference/google-cloud-datastore/2.4.0/Google-Cloud-Datastore)\n- [2.3.1](/ruby/docs/reference/google-cloud-datastore/2.3.1/Google-Cloud-Datastore)\n- [2.2.4](/ruby/docs/reference/google-cloud-datastore/2.2.4/Google-Cloud-Datastore) \nReference documentation and code samples for the Firestore in Datastore mode API module Google::Cloud::Datastore.\n\nGoogle Cloud Datastore\n----------------------\n\nGoogle Cloud Datastore is a fully managed, schemaless database for storing\nnon-relational data. You should feel at home if you are familiar with\nrelational databases, but there are some key differences to be aware of to\nmake the most of using Datastore.\n\nSee [Datastore Overview](./index.html \"Datastore Overview\").\n\nExample\n-------\n\n```ruby\nrequire \"google/cloud/datastore\"\n\ndatastore = Google::Cloud::Datastore.new(\n project_id: \"my-todo-project\",\n credentials: \"/path/to/keyfile.json\"\n)\n\ntask = datastore.find \"Task\", \"sampleTask\"\ntask[\"priority\"] = 5\ndatastore.save task\n```\n\nMethods\n-------\n\n### .configure\n\n def self.configure() -\u003e Google::Cloud::Config\n\nConfigure the Google Cloud Datastore library.\n\nThe following Datastore configuration parameters are supported:\n\n- `project_id` - (String) Identifier for a Datastore project. (The parameter `project` is considered deprecated, but may also be used.)\n- `credentials` - (String, Hash, Google::Auth::Credentials) The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See [Credentials](/ruby/docs/reference/google-cloud-datastore/latest/Google-Cloud-Datastore-Credentials \"Google::Cloud::Datastore::Credentials (class)\")) (The parameter `keyfile` is considered deprecated, but may also be used.)\n- `scope` - (String, Array\n- `quota_project` - (String) The project ID for a project that can be used by client libraries for quota and billing purposes.\n- `timeout` - (Integer) Default timeout to use in requests.\n- `endpoint` - (String) Override of the endpoint host name, or `nil` to use the default endpoint.\n- `emulator_host` - (String) Host name of the emulator. Defaults to `ENV[\"DATASTORE_EMULATOR_HOST\"]` \n**Yields**\n\n- (Google::Cloud.configure.datastore) \n**Returns**\n\n- (Google::Cloud::Config) --- The configuration object the Google::Cloud::Datastore library uses.\n\n### .new\n\n def self.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, emulator_host: nil, database_id: nil, project: nil, keyfile: nil) -\u003e Google::Cloud::Datastore::Dataset\n\nCreates a new object for connecting to the Datastore service.\nEach call creates a new connection.\n\n\n\u003cbr /\u003e\n\nFor more information on connecting to Google Cloud see the\n[Authentication Guide](./AUTHENTICATION \"Authentication Guide\"). \n**Parameters**\n\n- **project_id** (String) *(defaults to: nil)* --- Identifier for a Datastore project. If not present, the default project for the credentials is used.\n- **credentials** (String, Hash, Google::Auth::Credentials) *(defaults to: nil)* --- The path to the keyfile as a String, the contents of the keyfile as a Hash, or a Google::Auth::Credentials object. (See [Credentials](/ruby/docs/reference/google-cloud-datastore/latest/Google-Cloud-Datastore-Credentials \"Google::Cloud::Datastore::Credentials (class)\"))\n- **scope** (String, Array\\\u003cString\\\u003e) *(defaults to: nil)* ---\n\n The OAuth 2.0 scopes controlling\n the set of resources and operations that the connection can access.\n See [Using OAuth 2.0 to Access Google\n APIs](https://developers.google.com/identity/protocols/OAuth2).\n\n The default scope is:\n - `https://www.googleapis.com/auth/datastore`\n- **timeout** (Integer) *(defaults to: nil)* --- Default timeout to use in requests. Optional.\n- **endpoint** (String) *(defaults to: nil)* --- Override of the endpoint host name. Optional. If the param is nil, uses the default endpoint.\n- **emulator_host** (String) *(defaults to: nil)* --- Datastore emulator host. Optional. If the param is nil, uses the value of the `emulator_host` config.\n- **database_id** (String) *(defaults to: nil)* --- Identifier for a Datastore database in the project. If not present, the default database of the project will be used.\n- **project** (String) *(defaults to: nil)* --- Alias for the `project_id` argument. Deprecated.\n- **keyfile** (String) *(defaults to: nil)* --- Alias for the `credentials` argument. Deprecated. \n**Returns**\n\n- ([Google::Cloud::Datastore::Dataset](./Google-Cloud-Datastore-Dataset)) \n**Raises**\n\n- (ArgumentError)\n**Example** \n\n```ruby\nrequire \"google/cloud/datastore\"\n\ndatastore = Google::Cloud::Datastore.new(\n project_id: \"my-todo-project\",\n credentials: \"/path/to/keyfile.json\"\n)\n\ntask = datastore.entity \"Task\", \"sampleTask\" do |t|\n t[\"type\"] = \"Personal\"\n t[\"done\"] = false\n t[\"priority\"] = 4\n t[\"description\"] = \"Learn Cloud Datastore\"\nend\n\ndatastore.save task\n```\n\nConstants\n---------\n\n### VERSION\n\n**value:**\"2.13.0\".freeze"]]