MongoDB C++ Driver
mongocxx-3.0.2
|
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. | |
pipeline & | operator= (pipeline &&) noexcept |
Move assigns a pipeline. | |
~pipeline () | |
Destroys a pipeline. | |
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. More... | |
pipeline & | limit (std::int32_t limit) |
Limits the number of documents passed to the next stage in the pipeline. More... | |
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. More... | |
pipeline & | match (bsoncxx::document::view_or_value filter) |
Filters the documents. More... | |
pipeline & | out (std::string collection_name) |
Takes documents returned by the aggregation pipeline and writes them to a specified collection. More... | |
pipeline & | project (bsoncxx::document::view_or_value projection) |
Projects a subset of the fields in the documents to the next stage of the pipeline. More... | |
pipeline & | redact (bsoncxx::document::view_or_value restrictions) |
Restricts the contents of the documents based on information stored in the documents themselves. More... | |
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. More... | |
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. More... | |
pipeline & | sort (bsoncxx::document::view_or_value ordering) |
Sorts all input documents and returns them to the pipeline in sorted order. More... | |
pipeline & | unwind (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 |
Class representing a MongoDB aggregation pipeline.
mongocxx::pipeline::pipeline | ( | ) |
Creates a new aggregation pipeline.
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.
group | the 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.
limit | the 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.
lookup | the 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.
filter | the 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.
collection_name | the 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.
projection | projection 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.
restrictions | the 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.
size | the 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.
skip | the 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.
ordering | document 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.
field_name | the name of the field to unwind. |
bsoncxx::document::view mongocxx::pipeline::view | ( | ) | const |