Class: Google::Apis::FirestoreV1::Aggregation

Inherits:
Object
  • Object
show all
Includes:
Core::Hashable, Core::JsonObjectSupport
Defined in:
lib/google/apis/firestore_v1/classes.rb,
lib/google/apis/firestore_v1/representations.rb,
lib/google/apis/firestore_v1/representations.rb

Overview

Defines an aggregation that produces a single result.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ Aggregation

Returns a new instance of Aggregation.



73
74
75
# File 'lib/google/apis/firestore_v1/classes.rb', line 73

def initialize(**args)
   update!(**args)
end

Instance Attribute Details

#aliasString

Optional. Optional name of the field to store the result of the aggregation into. If not provided, Firestore will pick a default name following the format field_. For example: AGGREGATE COUNT_UP_TO(1) AS count_up_to_1, COUNT_UP_TO(2), COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) OVER ( ... ); becomes: AGGREGATE COUNT_UP_TO(1) AS count_up_to_1, COUNT_UP_TO(2) AS field_1, COUNT_UP_TO(3) AS count_up_to_3, COUNT(*) AS field_2 OVER ( ... ); Requires: * Must be unique across all aggregation aliases. * Conform to document field name limitations. Corresponds to the JSON property alias

Returns:

  • (String)


39
40
41
# File 'lib/google/apis/firestore_v1/classes.rb', line 39

def alias
  @alias
end

#avgGoogle::Apis::FirestoreV1::Avg

Average of the values of the requested field. * Only numeric values will be aggregated. All non-numeric values including NULL are skipped. * If the aggregated values contain NaN, returns NaN. Infinity math follows IEEE-754 standards. * If the aggregated value set is empty, returns NULL. * Always returns the result as a double. Corresponds to the JSON property avg



48
49
50
# File 'lib/google/apis/firestore_v1/classes.rb', line 48

def avg
  @avg
end

#countGoogle::Apis::FirestoreV1::Count

Count of documents that match the query. The COUNT(*) aggregation function operates on the entire document so it does not require a field reference. Corresponds to the JSON property count



54
55
56
# File 'lib/google/apis/firestore_v1/classes.rb', line 54

def count
  @count
end

#sumGoogle::Apis::FirestoreV1::Sum

Sum of the values of the requested field. * Only numeric values will be aggregated. All non-numeric values including NULL are skipped. * If the aggregated values contain NaN, returns NaN. Infinity math follows IEEE-754 standards. * If the aggregated value set is empty, returns 0. * Returns a 64- bit integer if all aggregated numbers are integers and the sum result does not overflow. Otherwise, the result is returned as a double. Note that even if all the aggregated values are integers, the result is returned as a double if it cannot fit within a 64-bit signed integer. When this occurs, the returned value will lose precision. * When underflow occurs, floating-point aggregation is non-deterministic. This means that running the same query repeatedly without any changes to the underlying values could produce slightly different results each time. In those cases, values should be stored as integers over floating-point numbers. Corresponds to the JSON property sum



71
72
73
# File 'lib/google/apis/firestore_v1/classes.rb', line 71

def sum
  @sum
end

Instance Method Details

#update!(**args) ⇒ Object

Update properties of this object



78
79
80
81
82
83
# File 'lib/google/apis/firestore_v1/classes.rb', line 78

def update!(**args)
  @alias = args[:alias] if args.key?(:alias)
  @avg = args[:avg] if args.key?(:avg)
  @count = args[:count] if args.key?(:count)
  @sum = args[:sum] if args.key?(:sum)
end