MongoDB C++ Driver  mongocxx-3.0.2
Public Member Functions | List of all members
mongocxx::pipeline Class Reference

Class representing a MongoDB aggregation pipeline. More...

#include <pipeline.hpp>

Public Member Functions

 pipeline ()
 Creates a new aggregation pipeline. More...
 
 pipeline (pipeline &&) noexcept
 Move constructs a pipeline.
 
pipelineoperator= (pipeline &&) noexcept
 Move assigns a pipeline.
 
 ~pipeline ()
 Destroys a pipeline.
 
pipelinegroup (bsoncxx::document::view_or_value group)
 Groups documents by some specified expression and outputs to the next stage a document for each distinct grouping. More...
 
pipelinelimit (std::int32_t limit)
 Limits the number of documents passed to the next stage in the pipeline. More...
 
pipelinelookup (bsoncxx::document::view_or_value lookup)
 Performs a left outer join to an unsharded collection in the same database to filter in documents from the "joined" collection for processing. More...
 
pipelinematch (bsoncxx::document::view_or_value filter)
 Filters the documents. More...
 
pipelineout (std::string collection_name)
 Takes documents returned by the aggregation pipeline and writes them to a specified collection. More...
 
pipelineproject (bsoncxx::document::view_or_value projection)
 Projects a subset of the fields in the documents to the next stage of the pipeline. More...
 
pipelineredact (bsoncxx::document::view_or_value restrictions)
 Restricts the contents of the documents based on information stored in the documents themselves. More...
 
pipelinesample (std::int32_t size)
 Randomly selects the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline. More...
 
pipelineskip (std::int32_t skip)
 Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline. More...
 
pipelinesort (bsoncxx::document::view_or_value ordering)
 Sorts all input documents and returns them to the pipeline in sorted order. More...
 
pipelineunwind (std::string field_name)
 Deconstructs an array field from the input documents to output a document for each element. More...
 
bsoncxx::document::view view () const
 

Detailed Description

Class representing a MongoDB aggregation pipeline.

Constructor & Destructor Documentation

mongocxx::pipeline::pipeline ( )

Creates a new aggregation pipeline.

See also
http://docs.mongodb.org/manual/core/aggregation-pipeline/

Member Function Documentation

pipeline& mongocxx::pipeline::group ( bsoncxx::document::view_or_value  group)

Groups documents by some specified expression and outputs to the next stage a document for each distinct grouping.

The output documents contain an _id field which contains the the distinct key for that group. The output documents can also contain computed fields that hold the values of some accumulator expression grouped by the group's _id field.

Note
group does not order output documents.
See also
http://docs.mongodb.org/manual/reference/operator/aggregation/group/#pipe._S_group
Parameters
groupthe group expression, as a document.
pipeline& mongocxx::pipeline::limit ( std::int32_t  limit)

Limits the number of documents passed to the next stage in the pipeline.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/limit/#pipe._S_limit
Parameters
limitthe number of documents to which output should be limited.
pipeline& mongocxx::pipeline::lookup ( bsoncxx::document::view_or_value  lookup)

Performs a left outer join to an unsharded collection in the same database to filter in documents from the "joined" collection for processing.

See also
https://docs.mongodb.org/manual/reference/operator/aggregation/lookup/
Parameters
lookupthe lookup expression, as a document with the following fields: from: <collection to="" join>=""> localField: <field from="" the="" input="" documents>=""> foreignField: <field from the documents of the "from" collection> as: <output array="" field>="">
pipeline& mongocxx::pipeline::match ( bsoncxx::document::view_or_value  filter)

Filters the documents.

Only the documents that match the condition(s) specified by the filter will continue to the next pipeline stage.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/match/#pipe._S_match
Parameters
filterthe filter.
pipeline& mongocxx::pipeline::out ( std::string  collection_name)

Takes documents returned by the aggregation pipeline and writes them to a specified collection.

This stage must be the last stage in the pipeline. The out operator lets the aggregation framework return result sets of any size.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/out/#pipe._S_out
Parameters
collection_namethe name of the collection where the output documents should go
pipeline& mongocxx::pipeline::project ( bsoncxx::document::view_or_value  projection)

Projects a subset of the fields in the documents to the next stage of the pipeline.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/project/#pipe._S_project
Parameters
projectionprojection specification.
pipeline& mongocxx::pipeline::redact ( bsoncxx::document::view_or_value  restrictions)

Restricts the contents of the documents based on information stored in the documents themselves.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/redact/#pipe._S_redact
Parameters
restrictionsthe document restrictions.
pipeline& mongocxx::pipeline::sample ( std::int32_t  size)

Randomly selects the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/sample/#pipe._S_sample
Parameters
sizethe number of input documents to select.
pipeline& mongocxx::pipeline::skip ( std::int32_t  skip)

Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/skip/#pipe._S_skip
Parameters
skipthe number of input documents to skip.
pipeline& mongocxx::pipeline::sort ( bsoncxx::document::view_or_value  ordering)

Sorts all input documents and returns them to the pipeline in sorted order.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/sort/#pipe._S_sort
Parameters
orderingdocument specifying the ordering by which the documents are sorted.
pipeline& mongocxx::pipeline::unwind ( std::string  field_name)

Deconstructs an array field from the input documents to output a document for each element.

Each output document is an input document with the value of its array field replaced by an element from the unwound array.

See also
http://docs.mongodb.org/manual/reference/operator/aggregation/unwind/#pipe._S_unwind
Parameters
field_namethe name of the field to unwind.
bsoncxx::document::view mongocxx::pipeline::view ( ) const
Returns
A view of the underlying BSON document this pipeline represents.

The documentation for this class was generated from the following file: