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:



6440
6441
6442
6443
# File 'lib/parse/query.rb', line 6440

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

#countGroupedResult

Count the number of items in each group.

Returns:



6424
6425
6426
6427
# File 'lib/parse/query.rb', line 6424

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

#listGroupedResult

Collect Parse::Object instances per group.

Returns:



6465
6466
6467
6468
# File 'lib/parse/query.rb', line 6465

def list
  results = super
  GroupedResult.new(results)
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:



6458
6459
6460
6461
# File 'lib/parse/query.rb', line 6458

def max(field)
  results = super
  GroupedResult.new(results)
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:



6450
6451
6452
6453
# File 'lib/parse/query.rb', line 6450

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

#sum(field) ⇒ GroupedResult

Sum a field for each group.

Parameters:

  • field (Symbol, String)

    the field to sum within each group.

Returns:



6432
6433
6434
6435
# File 'lib/parse/query.rb', line 6432

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