Class: Parse::SortableGroupBy

Inherits:
GroupBy
  • Object
show all
Defined in:
lib/parse/query.rb

Overview

Sortable version of GroupBy that returns GroupedResult objects instead of plain hashes. Provides the same aggregation methods but with sorting capabilities.

Instance Method Summary collapse

Methods inherited from GroupBy

#initialize, #order, #pipeline, #raw, #sort

Constructor Details

This class inherits a constructor from Parse::GroupBy

Instance Method Details

#average(field) ⇒ GroupedResult Also known as: avg

Calculate average of a field for each group.

Parameters:

  • field (Symbol, String) —

    the field to average within each group.

Returns:



8955
8956
8957
8958
# File 'lib/parse/query.rb', line 8955

def average(field)
  results = super
  GroupedResult.new(results, "average")
end

#count ⇒ GroupedResult

Count the number of items in each group.

Returns:



8939
8940
8941
8942
# File 'lib/parse/query.rb', line 8939

def count
  results = super
  GroupedResult.new(results, "count")
end

#list ⇒ GroupedResult

Collect Parse::Object instances per group.

Returns:



8980
8981
8982
8983
# File 'lib/parse/query.rb', line 8980

def list
  results = super
  GroupedResult.new(results, "list")
end

#max(field) ⇒ GroupedResult

Find maximum value of a field for each group.

Parameters:

  • field (Symbol, String) —

    the field to find maximum for within each group.

Returns:



8973
8974
8975
8976
# File 'lib/parse/query.rb', line 8973

def max(field)
  results = super
  GroupedResult.new(results, "max")
end

#min(field) ⇒ GroupedResult

Find minimum value of a field for each group.

Parameters:

  • field (Symbol, String) —

    the field to find minimum for within each group.

Returns:



8965
8966
8967
8968
# File 'lib/parse/query.rb', line 8965

def min(field)
  results = super
  GroupedResult.new(results, "min")
end

#sum(field) ⇒ GroupedResult

Sum a field for each group.

Parameters:

  • field (Symbol, String) —

    the field to sum within each group.

Returns:



8947
8948
8949
8950
# File 'lib/parse/query.rb', line 8947

def sum(field)
  results = super
  GroupedResult.new(results, "sum")
end