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:



6774
6775
6776
6777
# File 'lib/parse/query.rb', line 6774

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

#countGroupedResult

Count the number of items in each group.

Returns:



6758
6759
6760
6761
# File 'lib/parse/query.rb', line 6758

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

#listGroupedResult

Collect Parse::Object instances per group.

Returns:



6799
6800
6801
6802
# File 'lib/parse/query.rb', line 6799

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:



6792
6793
6794
6795
# File 'lib/parse/query.rb', line 6792

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:



6784
6785
6786
6787
# File 'lib/parse/query.rb', line 6784

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:



6766
6767
6768
6769
# File 'lib/parse/query.rb', line 6766

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