google-cloud-datastore 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/lib/google/cloud/datastore/read_only_transaction.rb +152 -6
- data/lib/google/cloud/datastore/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72ce967e2225a7f45b099b3183e72b450e2a424540423ccdbcecd3f04d4df5a7
|
4
|
+
data.tar.gz: 7bc5dc5ef826d16c6e3732ed496deacb53e239c3a0583fa46babeeb5253bc91c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0babd961bc284b94502cb3dcccfa5da0fea60fd6277ca5c8da2a5527e9cde189d0d18eb1ac6d3b66f0f1676e81d0eddfdd5e068cbfe3a3da0c1f07e05651fb34
|
7
|
+
data.tar.gz: 03d6099865662209ce9824bfd3601391b78996d62377b34d80bbaff2c8f9b25fe04ff8c8563aa8fcdf24a000850d20df1243ddd96b963ca80a2906475ea1f421
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 1.5.1 / 2019-02-13
|
4
|
+
|
5
|
+
* Add `ReadOnlyTransaction` convenience methods:
|
6
|
+
* Add `ReadOnlyTransaction#query`
|
7
|
+
* Add `ReadOnlyTransaction#gql`
|
8
|
+
* Add `ReadOnlyTransaction#key`
|
9
|
+
|
3
10
|
### 1.5.0 / 2019-02-01
|
4
11
|
|
5
12
|
* Make use of Credentials#project_id
|
@@ -8,7 +15,7 @@
|
|
8
15
|
This value was added in googleauth 0.7.0.
|
9
16
|
* Loosen googleauth dependency
|
10
17
|
Allow for new releases up to 0.10.
|
11
|
-
The googleauth devs have committed to
|
18
|
+
The googleauth devs have committed to maintaining the current API
|
12
19
|
and will not make backwards compatible changes before 0.10.
|
13
20
|
|
14
21
|
### 1.4.4 / 2018-09-20
|
@@ -139,9 +139,9 @@ module Google
|
|
139
139
|
#
|
140
140
|
# datastore = Google::Cloud::Datastore.new
|
141
141
|
#
|
142
|
-
# query = datastore.query("Task").
|
143
|
-
# where("done", "=", false)
|
144
142
|
# datastore.read_only_transaction do |tx|
|
143
|
+
# query = tx.query("Task").
|
144
|
+
# where("done", "=", false)
|
145
145
|
# tasks = tx.run query
|
146
146
|
# end
|
147
147
|
#
|
@@ -179,12 +179,12 @@ module Google
|
|
179
179
|
# datastore = Google::Cloud::Datastore.new
|
180
180
|
#
|
181
181
|
# task_list_key = datastore.key "TaskList", "default"
|
182
|
-
# query = datastore.query("Task").
|
183
|
-
# ancestor(task_list_key)
|
184
182
|
#
|
185
183
|
# tx = datastore.transaction
|
186
184
|
# task_list = tx.find task_list_key
|
187
185
|
# if task_list
|
186
|
+
# query = tx.query("Task").
|
187
|
+
# ancestor(task_list_key)
|
188
188
|
# tasks = tx.run query
|
189
189
|
# end
|
190
190
|
# tx.commit
|
@@ -209,12 +209,12 @@ module Google
|
|
209
209
|
# datastore = Google::Cloud::Datastore.new
|
210
210
|
#
|
211
211
|
# task_list_key = datastore.key "TaskList", "default"
|
212
|
-
# query = datastore.query("Task").
|
213
|
-
# ancestor(task_list_key)
|
214
212
|
#
|
215
213
|
# tx = datastore.transaction
|
216
214
|
# task_list = tx.find task_list_key
|
217
215
|
# if task_list
|
216
|
+
# query = tx.query("Task").
|
217
|
+
# ancestor(task_list_key)
|
218
218
|
# tasks = tx.run query
|
219
219
|
# end
|
220
220
|
# tx.rollback
|
@@ -236,6 +236,152 @@ module Google
|
|
236
236
|
@id = nil
|
237
237
|
end
|
238
238
|
|
239
|
+
##
|
240
|
+
# Create a new Query instance. This is a convenience method to make the
|
241
|
+
# creation of Query objects easier.
|
242
|
+
#
|
243
|
+
# @param [String] kinds The kind of entities to query. This is optional.
|
244
|
+
#
|
245
|
+
# @return [Google::Cloud::Datastore::Query]
|
246
|
+
#
|
247
|
+
# @example
|
248
|
+
# require "google/cloud/datastore"
|
249
|
+
#
|
250
|
+
# datastore = Google::Cloud::Datastore.new
|
251
|
+
#
|
252
|
+
# datastore.read_only_transaction do |tx|
|
253
|
+
# query = tx.query("Task").
|
254
|
+
# where("done", "=", false)
|
255
|
+
# tasks = tx.run query
|
256
|
+
# end
|
257
|
+
#
|
258
|
+
def query *kinds
|
259
|
+
query = Query.new
|
260
|
+
query.kind(*kinds) unless kinds.empty?
|
261
|
+
query
|
262
|
+
end
|
263
|
+
|
264
|
+
##
|
265
|
+
# Create a new GqlQuery instance. This is a convenience method to make
|
266
|
+
# the creation of GqlQuery objects easier.
|
267
|
+
#
|
268
|
+
# @param [String] query The GQL query string.
|
269
|
+
# @param [Hash] bindings Named bindings for the GQL query string, each
|
270
|
+
# key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match
|
271
|
+
# regex `__.*__`, and must not be `""`. The value must be an `Object`
|
272
|
+
# that can be stored as an Entity property value, or a `Cursor`.
|
273
|
+
#
|
274
|
+
# @return [Google::Cloud::Datastore::GqlQuery]
|
275
|
+
#
|
276
|
+
# @example
|
277
|
+
# require "google/cloud/datastore"
|
278
|
+
#
|
279
|
+
# datastore = Google::Cloud::Datastore.new
|
280
|
+
#
|
281
|
+
# datastore.read_only_transaction do |tx|
|
282
|
+
# gql_query = tx.gql "SELECT * FROM Task WHERE done = @done",
|
283
|
+
# done: false
|
284
|
+
# tasks = tx.run gql_query
|
285
|
+
# end
|
286
|
+
#
|
287
|
+
# @example The previous example is equivalent to:
|
288
|
+
# require "google/cloud/datastore"
|
289
|
+
#
|
290
|
+
# datastore = Google::Cloud::Datastore.new
|
291
|
+
#
|
292
|
+
# datastore.read_only_transaction do |tx|
|
293
|
+
# gql_query = Google::Cloud::Datastore::GqlQuery.new
|
294
|
+
# gql_query.query_string = "SELECT * FROM Task WHERE done = @done"
|
295
|
+
# gql_query.named_bindings = {done: false}
|
296
|
+
# tasks = tx.run gql_query
|
297
|
+
# end
|
298
|
+
#
|
299
|
+
def gql query, bindings = {}
|
300
|
+
gql = GqlQuery.new
|
301
|
+
gql.query_string = query
|
302
|
+
gql.named_bindings = bindings unless bindings.empty?
|
303
|
+
gql
|
304
|
+
end
|
305
|
+
|
306
|
+
##
|
307
|
+
# Create a new Key instance. This is a convenience method to make the
|
308
|
+
# creation of Key objects easier.
|
309
|
+
#
|
310
|
+
# @param [Array<Array(String,(String|Integer|nil))>] path An optional
|
311
|
+
# list of pairs for the key's path. Each pair may include the key's
|
312
|
+
# kind (String) and an id (Integer) or name (String). This is
|
313
|
+
# optional.
|
314
|
+
# @param [String] project The project of the Key. This is optional.
|
315
|
+
# @param [String] namespace namespace kind of the Key. This is optional.
|
316
|
+
#
|
317
|
+
# @return [Google::Cloud::Datastore::Key]
|
318
|
+
#
|
319
|
+
# @example
|
320
|
+
# require "google/cloud/datastore"
|
321
|
+
#
|
322
|
+
# datastore = Google::Cloud::Datastore.new
|
323
|
+
#
|
324
|
+
# datastore.read_only_transaction do |tx|
|
325
|
+
# task_key = tx.key "Task", "sampleTask"
|
326
|
+
# end
|
327
|
+
#
|
328
|
+
# @example The previous example is equivalent to:
|
329
|
+
# require "google/cloud/datastore"
|
330
|
+
#
|
331
|
+
# datastore = Google::Cloud::Datastore.new
|
332
|
+
#
|
333
|
+
# datastore.read_only_transaction do |tx|
|
334
|
+
# task_key = Google::Cloud::Datastore::Key.new "Task", "sampleTask"
|
335
|
+
# end
|
336
|
+
#
|
337
|
+
# @example Create a key with a parent:
|
338
|
+
# require "google/cloud/datastore"
|
339
|
+
#
|
340
|
+
# datastore = Google::Cloud::Datastore.new
|
341
|
+
#
|
342
|
+
# datastore.read_only_transaction do |tx|
|
343
|
+
# key = tx.key [["TaskList", "default"], ["Task", "sampleTask"]]
|
344
|
+
# results = tx.find_all key
|
345
|
+
# end
|
346
|
+
#
|
347
|
+
# @example Create a key with multi-level ancestry:
|
348
|
+
# require "google/cloud/datastore"
|
349
|
+
#
|
350
|
+
# datastore = Google::Cloud::Datastore.new
|
351
|
+
#
|
352
|
+
# datastore.read_only_transaction do |tx|
|
353
|
+
# key = tx.key([
|
354
|
+
# ["User", "alice"],
|
355
|
+
# ["TaskList", "default"],
|
356
|
+
# ["Task", "sampleTask"]
|
357
|
+
# ])
|
358
|
+
# results = tx.find_all key
|
359
|
+
# end
|
360
|
+
#
|
361
|
+
# @example Create a key with a project and namespace:
|
362
|
+
# require "google/cloud/datastore"
|
363
|
+
#
|
364
|
+
# datastore = Google::Cloud::Datastore.new
|
365
|
+
#
|
366
|
+
# datastore.read_only_transaction do |tx|
|
367
|
+
# key = tx.key ["TaskList", "default"], ["Task", "sampleTask"],
|
368
|
+
# project: "my-todo-project",
|
369
|
+
# namespace: "example-ns"
|
370
|
+
# results = tx.find_all key
|
371
|
+
# end
|
372
|
+
#
|
373
|
+
def key *path, project: nil, namespace: nil
|
374
|
+
path = path.flatten.each_slice(2).to_a # group in pairs
|
375
|
+
kind, id_or_name = path.pop
|
376
|
+
Key.new(kind, id_or_name).tap do |k|
|
377
|
+
k.project = project
|
378
|
+
k.namespace = namespace
|
379
|
+
unless path.empty?
|
380
|
+
k.parent = key path, project: project, namespace: namespace
|
381
|
+
end
|
382
|
+
end
|
383
|
+
end
|
384
|
+
|
239
385
|
protected
|
240
386
|
|
241
387
|
##
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-datastore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Moore
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-02-
|
12
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: google-cloud-core
|