google-cloud-datastore
Google Cloud Datastore (docs) is a fully managed, schemaless database for storing non-relational data. Cloud Datastore automatically scales with your users and supports ACID transactions, high availability of reads and writes, strong consistency for reads and ancestor queries, and eventual consistency for all other queries.
Follow the activation instructions to use the Google Cloud Datastore API with your project.
- google-cloud-datastore API documentation
- google-cloud-datastore on RubyGems
- Google Cloud Datastore documentation
Quick Start
$ gem install google-cloud-datastore
Authentication
This library uses Service Account credentials to connect to Google Cloud services. When running on Compute Engine the credentials will be discovered automatically. When running on other environments the Service Account credentials can be specified by providing the path to the JSON file, or the JSON itself, in environment variables.
Instructions and configuration options are covered in the Authentication Guide.
Example
require "google/cloud/datastore"
datastore = Google::Cloud::Datastore.new(
project_id: "my-todo-project",
credentials: "/path/to/keyfile.json"
)
# Create a new task to demo datastore
task = datastore.entity "Task", "sampleTask" do |t|
t["type"] = "Personal"
t["done"] = false
t["priority"] = 4
t["description"] = "Learn Cloud Datastore"
end
# Save the new task
datastore.save task
# Run a query for all completed tasks
query = datastore.query("Task").
where("done", "=", false)
tasks = datastore.run query
Supported Ruby Versions
This library is supported on Ruby 2.0+.
Versioning
This library follows Semantic Versioning.
Contributing
Contributions to this library are always welcome and highly encouraged.
See the Contributing Guide for more information on how to get started.
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.
License
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
Support
Please report bugs at the project on Github. Don't hesitate to ask questions about the client or APIs on StackOverflow.