MongoDB C++ Driver mongocxx-3.1.1
Loading...
Searching...
No Matches
pipeline.hpp
1// Copyright 2014 MongoDB Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <cstdint>
18#include <string>
19#include <memory>
20
21#include <bsoncxx/array/view.hpp>
22#include <bsoncxx/document/view.hpp>
23#include <bsoncxx/document/view_or_value.hpp>
24
25#include <mongocxx/config/prelude.hpp>
26
27namespace mongocxx {
28MONGOCXX_INLINE_NAMESPACE_BEGIN
29
30class collection;
31
35class MONGOCXX_API pipeline {
36 public:
43
47 pipeline(pipeline&&) noexcept;
48
52 pipeline& operator=(pipeline&&) noexcept;
53
58
69 pipeline& add_fields(bsoncxx::document::view_or_value fields_to_add);
70
81 pipeline& bucket(bsoncxx::document::view_or_value bucket_args);
82
94 pipeline& bucket_auto(bsoncxx::document::view_or_value bucket_auto_args);
95
105 pipeline& coll_stats(
106 bsoncxx::document::view_or_value coll_stats_args = bsoncxx::document::view{});
107
116 pipeline& count(std::string field);
117
129
140
151
167
174
183 pipeline& limit(std::int32_t limit);
184
196
207
218 pipeline& out(std::string collection_name);
219
229
240
251
261 pipeline& sample(std::int32_t size);
262
272 pipeline& skip(std::int32_t docs_to_skip);
273
283
298
313 pipeline& sort_by_count(std::string field_expression);
314
330
345 pipeline& unwind(std::string field_name);
346
351
357 MONGOCXX_DEPRECATED bsoncxx::document::view view() const;
358
359 private:
360 friend class collection;
361
362 class MONGOCXX_PRIVATE impl;
363 std::unique_ptr<impl> _impl;
364};
365
366MONGOCXX_INLINE_NAMESPACE_END
367} // namespace mongocxx
368
369#include <mongocxx/config/postlude.hpp>
A read-only, non-owning view of a BSON document.
Definition view.hpp:33
A read-only, non-owning view of a BSON document.
Definition view.hpp:33
Class representing server side document groupings within a MongoDB database.
Definition collection.hpp:74
Class representing a MongoDB aggregation pipeline.
Definition pipeline.hpp:35
pipeline & sample(std::int32_t size)
Randomly selects the specified number of documents that pass into the stage and passes the remaining ...
pipeline & match(bsoncxx::document::view_or_value filter)
Filters the documents.
pipeline & facet(bsoncxx::document::view_or_value facet_args)
Processes multiple aggregation pipelines within a single stage on the same set of input documents.
pipeline(pipeline &&) noexcept
Move constructs a pipeline.
pipeline & group(bsoncxx::document::view_or_value group_args)
Groups documents by some specified expression and outputs to the next stage a document for each disti...
pipeline & unwind(bsoncxx::document::view_or_value unwind_args)
Deconstructs an array field from the input documents to output a document for each element.
pipeline & count(std::string field)
Returns a document containing a count of the number of documents input to the stage.
pipeline & sort_by_count(std::string field_expression)
Groups incoming documents based on the value of a specified expression, then computes the count of do...
bsoncxx::array::view view_array() const
pipeline & unwind(std::string field_name)
Deconstructs an array field from the input documents to output a document for each element.
pipeline & lookup(bsoncxx::document::view_or_value lookup_args)
Performs a left outer join to an unsharded collection in the same database to filter in documents fro...
pipeline & skip(std::int32_t docs_to_skip)
Skips over the specified number of documents that pass into the stage and passes the remaining docume...
pipeline & limit(std::int32_t limit)
Limits the number of documents passed to the next stage in the pipeline.
pipeline & geo_near(bsoncxx::document::view_or_value geo_near_args)
Outputs documents in order of nearest to farthest from a specified point.
pipeline & sort_by_count(bsoncxx::document::view_or_value field_expression)
Groups incoming documents based on the value of a specified expression, then computes the count of do...
pipeline & redact(bsoncxx::document::view_or_value restrictions)
Restricts the contents of the documents based on information stored in the documents themselves.
pipeline()
Creates a new aggregation pipeline.
pipeline & index_stats()
Returns statistics regarding the use of each index for the collection.
bsoncxx::document::view view() const
pipeline & graph_lookup(bsoncxx::document::view_or_value graph_lookup_args)
Performs a recursive search on a collection.
pipeline & replace_root(bsoncxx::document::view_or_value replace_root_args)
Promotes a specified document to the top level and replaces all other fields.
pipeline & out(std::string collection_name)
Takes documents returned by the aggregation pipeline and writes them to a specified collection.
pipeline & project(bsoncxx::document::view_or_value projection)
Projects a subset of the fields in the documents to the next stage of the pipeline.
pipeline & sort(bsoncxx::document::view_or_value ordering)
Sorts all input documents and returns them to the pipeline in sorted order.
Top level namespace for MongoDB C++ BSON functionality.
Definition element.hpp:24
Top level namespace for the MongoDB C++ driver.
Definition bulk_write.hpp:22