Class Origin::Pipeline
In: lib/origin/pipeline.rb
Parent: Array

Represents an aggregation pipeline.

@since 2.0.0

Methods

__deep_copy__   group   new   project   unwind  

Attributes

aliases  [R]  @attribute [r] aliases The field aliases.

Public Class methods

Initialize the new pipeline.

@example Initialize the new pipeline.

  Origin::Pipeline.new(aliases)

@param [ Hash ] aliases A hash of mappings from aliases to the actual

  field names in the database.

@since 2.0.0

Public Instance methods

Deep copy the aggregation pipeline. Will clone all the values in the pipeline as well as the pipeline itself.

@example Deep copy the pipeline.

  pipeline.__deep_copy__

@return [ Pipeline ] The cloned pipeline.

@since 2.0.0

Add a group operation to the aggregation pipeline.

@example Add a group operation.

  pipeline.group(:count.sum => 1, :max.max => "likes")

@param [ Hash ] entry The group entry.

@return [ Pipeline ] The pipeline.

@since 2.0.0

Adds a $project entry to the aggregation pipeline.

@example Add the projection.

  pipeline.project(name: 1)

@param [ Hash ] entry The projection.

@return [ Pipeline ] The pipeline.

Add the $unwind entry to the pipeline.

@example Add the unwind.

  pipeline.unwind(:field)

@param [ String, Symbol ] field The name of the field.

@return [ Pipeline ] The pipeline.

@since 2.0.0

[Validate]