MongoDB C++ Driver  mongocxx-3.9.0
All Classes Namespaces Functions Typedefs Enumerations Enumerator Friends Pages
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 <memory>
19 #include <string>
20 
21 #include <bsoncxx/array/view.hpp>
22 #include <bsoncxx/array/view_or_value.hpp>
23 #include <bsoncxx/document/view.hpp>
24 #include <bsoncxx/document/view_or_value.hpp>
25 
26 #include <mongocxx/config/prelude.hpp>
27 
28 namespace mongocxx {
29 inline namespace v_noabi {
30 class client;
31 class collection;
32 class database;
33 
37 class MONGOCXX_API pipeline {
38  public:
45 
49  pipeline(pipeline&&) noexcept;
50 
54  pipeline& operator=(pipeline&&) noexcept;
55 
60 
75  pipeline& add_fields(bsoncxx::document::view_or_value fields_to_add);
76 
91  pipeline& bucket(bsoncxx::document::view_or_value bucket_args);
92 
108  pipeline& bucket_auto(bsoncxx::document::view_or_value bucket_auto_args);
109 
123  pipeline& coll_stats(
124  bsoncxx::document::view_or_value coll_stats_args = bsoncxx::document::view{});
125 
138  pipeline& count(std::string field);
139 
155  pipeline& current_op(bsoncxx::document::view_or_value current_op_args);
156 
171  pipeline& facet(bsoncxx::document::view_or_value facet_args);
172 
188  pipeline& append_stage(bsoncxx::document::view_or_value stage);
189 
205  pipeline& append_stages(bsoncxx::array::view_or_value stages);
206 
220  pipeline& geo_near(bsoncxx::document::view_or_value geo_near_args);
221 
235  pipeline& graph_lookup(bsoncxx::document::view_or_value graph_lookup_args);
236 
255  pipeline& group(bsoncxx::document::view_or_value group_args);
256 
267 
280  pipeline& limit(std::int32_t limit);
281 
295  pipeline& list_local_sessions(bsoncxx::document::view_or_value list_local_sessions_args);
296 
309  pipeline& list_sessions(bsoncxx::document::view_or_value list_sessions_args);
310 
325  pipeline& lookup(bsoncxx::document::view_or_value lookup_args);
326 
340  pipeline& match(bsoncxx::document::view_or_value filter);
341 
355  pipeline& merge(bsoncxx::document::view_or_value merge_args);
356 
371  pipeline& out(std::string collection_name);
372 
385  pipeline& project(bsoncxx::document::view_or_value projection);
386 
400  pipeline& redact(bsoncxx::document::view_or_value restrictions);
401 
415  pipeline& replace_root(bsoncxx::document::view_or_value replace_root_args);
416 
430  pipeline& sample(std::int32_t size);
431 
445  pipeline& skip(std::int32_t docs_to_skip);
446 
459  pipeline& sort(bsoncxx::document::view_or_value ordering);
460 
478  pipeline& sort_by_count(bsoncxx::document::view_or_value field_expression);
479 
498  pipeline& sort_by_count(std::string field_expression);
499 
518  pipeline& unwind(bsoncxx::document::view_or_value unwind_args);
519 
538  pipeline& unwind(std::string field_name);
539 
543  bsoncxx::array::view view_array() const;
544 
545  private:
546  friend class client;
547  friend class collection;
548  friend class database;
549 
550  class MONGOCXX_PRIVATE impl;
551  std::unique_ptr<impl> _impl;
552 };
553 
554 } // namespace v_noabi
555 } // namespace mongocxx
556 
557 #include <mongocxx/config/postlude.hpp>
Class representing a client connection to MongoDB.
Definition: client.hpp:54
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:85
Class representing a MongoDB database.
Definition: database.hpp:44
Class representing a MongoDB aggregation pipeline.
Definition: pipeline.hpp:37
pipeline & count(std::string field)
Returns a document containing a count of the number of documents input to the stage.
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 & geo_near(bsoncxx::document::view_or_value geo_near_args)
Outputs documents in order of nearest to farthest from a specified point.
pipeline & list_sessions(bsoncxx::document::view_or_value list_sessions_args)
Lists all sessions stored in the system.sessions collection in the config database.
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 & 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 & list_local_sessions(bsoncxx::document::view_or_value list_local_sessions_args)
Lists the sessions cached in memory by the mongod or mongos instance.
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 & redact(bsoncxx::document::view_or_value restrictions)
Restricts the contents of the documents based on information stored in the documents themselves.
pipeline & append_stage(bsoncxx::document::view_or_value stage)
Appends a stage to this pipeline object.
bsoncxx::array::view view_array() const
pipeline & sort(bsoncxx::document::view_or_value ordering)
Sorts all input documents and returns them to the pipeline in sorted order.
pipeline & current_op(bsoncxx::document::view_or_value current_op_args)
Returns a stream of documents containing information on active and/or dormant operations as well as i...
pipeline & sample(std::int32_t size)
Randomly selects the specified number of documents that pass into the stage and passes the remaining ...
pipeline()
Creates a new aggregation pipeline.
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 & replace_root(bsoncxx::document::view_or_value replace_root_args)
Promotes a specified document to the top level and replaces all other fields.
pipeline & append_stages(bsoncxx::array::view_or_value stages)
Appends stages to this pipeline object from the given bson array.
pipeline & limit(std::int32_t limit)
Limits the number of documents passed to the next stage in the pipeline.
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...
pipeline & unwind(std::string field_name)
Deconstructs an array field from the input documents to output a document for each element.
pipeline & index_stats()
Returns statistics regarding the use of each index for the collection.
pipeline & graph_lookup(bsoncxx::document::view_or_value graph_lookup_args)
Performs a recursive search on a collection.
pipeline & merge(bsoncxx::document::view_or_value merge_args)
Outputs the aggregation results to a collection.
pipeline & match(bsoncxx::document::view_or_value filter)
Filters the documents.
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 & out(std::string collection_name)
Takes documents returned by the aggregation pipeline and writes them to a specified collection.
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...
The top-level namespace for bsoncxx library entities.
Definition: element.hpp:24
The top-level namespace for mongocxx library entities.
Definition: bulk_write.hpp:24