google-cloud-firestore 2.9.0 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c5c050184924a624eb5f83c42f528334296cc01392d5a9b1d891d81c2b7f4e50
4
- data.tar.gz: '085ffdcff90414ab769e585164e331a4d27b1edcfed7341d6c09998aca4a58c6'
3
+ metadata.gz: 31a027bd1f01c1bd2568417742a77525e4e5659316a9e81ff123062d095b580c
4
+ data.tar.gz: d85d3a069d0f3f3847a10ea0963896c3be546f8452a1eb8eb06e9d7c664ec525
5
5
  SHA512:
6
- metadata.gz: d5b99c1fa86740df4973731ecf715158cfbb8025fc46833f7b78cf9102d78245106133aed9e92311d5ae0879289054bbc7c832396792141e0df09abc7e6d7357
7
- data.tar.gz: 9ccefface707ebaf31f3c8e7a998e7ae7f95713a9ec71df4e691d3be3997eadc528f95dfaf5de8bce00162a2c69856b704b198fd4ccea0376f4804451f1f4c77
6
+ metadata.gz: d6d1ebeb7079ce28256ab3348110fdbab52d73db16e0cf6d7a1ee27f343d9918d1b8a3e7225504c268a13d3e7371706028487e2a14fcbf0e2b7e2cf8dcbda371
7
+ data.tar.gz: 7c34ced999d1368fdc3e645e128197fc7e9cb51850bf39cb753b680bbd5d6a1f70ba3572be04d5ab4c909008104c8a5cd4f1144d24e630ebbebb8333fef6baf1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 2.9.1 (2023-02-03)
4
+
5
+ #### Bug Fixes
6
+
7
+ * Change "aggregate_alias" to optional param ([#20082](https://github.com/googleapis/google-cloud-ruby/issues/20082))
8
+
3
9
  ### 2.9.0 (2023-01-26)
4
10
 
5
11
  #### Features
@@ -38,7 +38,7 @@ module Google
38
38
  # .add_count
39
39
  #
40
40
  # aggregate_query.get do |aggregate_snapshot|
41
- # puts aggregate_snapshot.get('count')
41
+ # puts aggregate_snapshot.get
42
42
  # end
43
43
  #
44
44
  # @example Alias an aggregate query
@@ -102,7 +102,7 @@ module Google
102
102
  # .add_count
103
103
  #
104
104
  # aggregate_query.get do |aggregate_snapshot|
105
- # puts aggregate_snapshot.get('count')
105
+ # puts aggregate_snapshot.get
106
106
  # end
107
107
  #
108
108
  def add_count aggregate_alias: nil
@@ -135,7 +135,7 @@ module Google
135
135
  # .add_count
136
136
  #
137
137
  # aggregate_query.get do |aggregate_snapshot|
138
- # puts aggregate_snapshot.get('count')
138
+ # puts aggregate_snapshot.get
139
139
  # end
140
140
  #
141
141
  def get
@@ -34,16 +34,31 @@ module Google
34
34
  # .add_count
35
35
  #
36
36
  # aggregate_query.get do |aggregate_snapshot|
37
- # puts aggregate_snapshot.get('count')
37
+ # puts aggregate_snapshot.get
38
38
  # end
39
+ # @return [Integer] The aggregate value.
39
40
  #
41
+ # @example Alias an aggregate query
42
+ # require "google/cloud/firestore"
43
+ #
44
+ # firestore = Google::Cloud::Firestore.new
45
+ #
46
+ # query = firestore.col "cities"
47
+ #
48
+ # # Create an aggregate query
49
+ # aggregate_query = query.aggregate_query
50
+ # .add_count aggregate_alias: 'total'
51
+ #
52
+ # aggregate_query.get do |aggregate_snapshot|
53
+ # puts aggregate_snapshot.get('total')
54
+ # end
40
55
  class AggregateQuerySnapshot
41
56
  ##
42
57
  # Retrieves the aggregate data.
43
58
  #
44
- # @param [String] aggregate_alias The alias used
45
- # to access the aggregate value. For count, the
46
- # default value is "count".
59
+ # @param aggregate_alias [String] The alias used to access
60
+ # the aggregate value. For an AggregateQuery with a
61
+ # single aggregate field, this parameter can be omitted.
47
62
  #
48
63
  # @return [Integer] The aggregate value.
49
64
  #
@@ -59,9 +74,29 @@ module Google
59
74
  # .add_count
60
75
  #
61
76
  # aggregate_query.get do |aggregate_snapshot|
62
- # puts aggregate_snapshot.get('count')
77
+ # puts aggregate_snapshot.get
63
78
  # end
64
- def get aggregate_alias
79
+ # @return [Integer] The aggregate value.
80
+ #
81
+ # @example Alias an aggregate query
82
+ # require "google/cloud/firestore"
83
+ #
84
+ # firestore = Google::Cloud::Firestore.new
85
+ #
86
+ # query = firestore.col "cities"
87
+ #
88
+ # # Create an aggregate query
89
+ # aggregate_query = query.aggregate_query
90
+ # .add_count aggregate_alias: 'total'
91
+ #
92
+ # aggregate_query.get do |aggregate_snapshot|
93
+ # puts aggregate_snapshot.get('total')
94
+ # end
95
+ def get aggregate_alias = nil
96
+ if @aggregate_fields.count > 1 && aggregate_alias.nil?
97
+ raise ArgumentError, "Required param aggregate_alias for AggregateQuery with multiple aggregate fields"
98
+ end
99
+ aggregate_alias ||= @aggregate_fields.keys.first
65
100
  @aggregate_fields[aggregate_alias]
66
101
  end
67
102
 
@@ -286,9 +286,15 @@ module Google
286
286
  #
287
287
  # firestore = Google::Cloud::Firestore.new
288
288
  #
289
+ # query = firestore.col "cities"
290
+ #
291
+ # # Create an aggregate query
292
+ # aq = query.aggregate_query
293
+ # .add_count
294
+ #
289
295
  # firestore.transaction do |tx|
290
296
  # tx.get_aggregate aq do |aggregate_snapshot|
291
- # puts aggregate_snapshot.get('count')
297
+ # puts aggregate_snapshot.get
292
298
  # end
293
299
  # end
294
300
  #
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Firestore
19
- VERSION = "2.9.0".freeze
19
+ VERSION = "2.9.1".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-firestore
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-27 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-cloud-core