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:



6536
6537
6538
6539
# File 'lib/parse/query.rb', line 6536

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

#countGroupedResult

Count the number of items in each group.

Returns:



6520
6521
6522
6523
# File 'lib/parse/query.rb', line 6520

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

#listGroupedResult

Collect Parse::Object instances per group.

Returns:



6561
6562
6563
6564
# File 'lib/parse/query.rb', line 6561

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:



6554
6555
6556
6557
# File 'lib/parse/query.rb', line 6554

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:



6546
6547
6548
6549
# File 'lib/parse/query.rb', line 6546

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:



6528
6529
6530
6531
# File 'lib/parse/query.rb', line 6528

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