Module: Google::Cloud::Datastore
- Defined in:
- lib/google/cloud/datastore.rb,
lib/google/cloud/datastore/key.rb,
lib/google/cloud/datastore/query.rb,
lib/google/cloud/datastore/commit.rb,
lib/google/cloud/datastore/cursor.rb,
lib/google/cloud/datastore/entity.rb,
lib/google/cloud/datastore/errors.rb,
lib/google/cloud/datastore/filter.rb,
lib/google/cloud/datastore/convert.rb,
lib/google/cloud/datastore/dataset.rb,
lib/google/cloud/datastore/service.rb,
lib/google/cloud/datastore/version.rb,
lib/google/cloud/datastore/gql_query.rb,
lib/google/cloud/datastore/properties.rb,
lib/google/cloud/datastore/credentials.rb,
lib/google/cloud/datastore/transaction.rb,
lib/google/cloud/datastore/aggregate_query.rb,
lib/google/cloud/datastore/dataset/query_results.rb,
lib/google/cloud/datastore/read_only_transaction.rb,
lib/google/cloud/datastore/dataset/lookup_results.rb,
lib/google/cloud/datastore/dataset/aggregate_query_results.rb
Overview
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.
See Datastore Overview.
Defined Under Namespace
Classes: AggregateQuery, Commit, Credentials, Cursor, Dataset, Entity, Filter, GqlQuery, Key, KeyError, Properties, PropertyError, Query, ReadOnlyTransaction, Transaction, TransactionError
Constant Summary collapse
- VERSION =
"2.13.1".freeze
Class Method Summary collapse
-
.configure {|Google::Cloud.configure.datastore| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Datastore library.
-
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, emulator_host: nil, database_id: nil, project: nil, keyfile: nil) ⇒ Google::Cloud::Datastore::Dataset
Creates a new object for connecting to the Datastore service.
Class Method Details
.configure {|Google::Cloud.configure.datastore| ... } ⇒ Google::Cloud::Config
Configure the Google Cloud Datastore library.
The following Datastore configuration parameters are supported:
project_id- (String) Identifier for a Datastore project. (The parameterprojectis 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 parameterkeyfileis considered deprecated, but may also be used.)scope- (String, Array) The OAuth 2.0 scopes controlling the set of resources and operations that the connection can access. 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, ornilto use the default endpoint.emulator_host- (String) Host name of the emulator. Defaults toENV["DATASTORE_EMULATOR_HOST"]
194 195 196 197 198 |
# File 'lib/google/cloud/datastore.rb', line 194 def self.configure yield Google::Cloud.configure.datastore if block_given? Google::Cloud.configure.datastore end |
.new(project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, emulator_host: nil, database_id: nil, project: nil, keyfile: 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 the Authentication Guide.
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/google/cloud/datastore.rb', line 120 def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil, endpoint: nil, emulator_host: nil, database_id: nil, project: nil, keyfile: nil project_id = get_project_id project_id, project scope ||= configure.scope timeout ||= configure.timeout endpoint ||= configure.endpoint emulator_host ||= configure.emulator_host database_id ||= configure.database_id if emulator_host project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? return Datastore::Dataset.new( Datastore::Service.new( project_id, :this_channel_is_insecure, database_id, host: emulator_host, timeout: timeout ) ) end credentials ||= keyfile || default_credentials(scope: scope) unless credentials.is_a? Google::Auth::Credentials credentials = Datastore::Credentials.new credentials, scope: scope end if credentials.respond_to? :project_id project_id ||= credentials.project_id end project_id = project_id.to_s # Always cast to a string raise ArgumentError, "project_id is missing" if project_id.empty? Datastore::Dataset.new( Datastore::Service.new( project_id, credentials, database_id, host: endpoint, timeout: timeout ) ) end |