MongoDB C++ Driver  mongocxx-3.10.2
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 <mongocxx/client-fwd.hpp>
22 #include <mongocxx/collection-fwd.hpp>
23 #include <mongocxx/database-fwd.hpp>
24 #include <mongocxx/pipeline-fwd.hpp>
25 
26 #include <bsoncxx/array/view.hpp>
27 #include <bsoncxx/array/view_or_value.hpp>
28 #include <bsoncxx/document/view.hpp>
29 #include <bsoncxx/document/view_or_value.hpp>
30 
31 #include <mongocxx/config/prelude.hpp>
32 
33 namespace mongocxx {
34 namespace v_noabi {
35 
39 class pipeline {
40  public:
47 
51  pipeline(pipeline&&) noexcept;
52 
56  pipeline& operator=(pipeline&&) noexcept;
57 
62 
77  pipeline& add_fields(bsoncxx::v_noabi::document::view_or_value fields_to_add);
78 
93  pipeline& bucket(bsoncxx::v_noabi::document::view_or_value bucket_args);
94 
110  pipeline& bucket_auto(bsoncxx::v_noabi::document::view_or_value bucket_auto_args);
111 
125  pipeline& coll_stats(bsoncxx::v_noabi::document::view_or_value coll_stats_args =
126  bsoncxx::v_noabi::document::view{});
127 
140  pipeline& count(std::string field);
141 
158 
174 
191 
208 
223 
238 
258 
269 
282  pipeline& limit(std::int32_t limit);
283 
298  bsoncxx::v_noabi::document::view_or_value list_local_sessions_args);
299 
313 
329 
344 
359 
374  pipeline& out(std::string collection_name);
375 
389 
404 
419 
433  pipeline& sample(std::int32_t size);
434 
448  pipeline& skip(std::int32_t docs_to_skip);
449 
463 
482 
501  pipeline& sort_by_count(std::string field_expression);
502 
522 
541  pipeline& unwind(std::string field_name);
542 
547 
548  private:
549  friend ::mongocxx::v_noabi::client;
550  friend ::mongocxx::v_noabi::collection;
551  friend ::mongocxx::v_noabi::database;
552 
553  class MONGOCXX_PRIVATE impl;
554  std::unique_ptr<impl> _impl;
555 };
556 
557 } // namespace v_noabi
558 } // namespace mongocxx
559 
560 #include <mongocxx/config/postlude.hpp>
A read-only, non-owning view of a BSON document.
Definition: view.hpp:36
Class representing a MongoDB aggregation pipeline.
Definition: pipeline.hpp:39
pipeline & match(bsoncxx::v_noabi::document::view_or_value filter)
Filters the documents.
pipeline & count(std::string field)
Returns a document containing a count of the number of documents input to the stage.
pipeline & redact(bsoncxx::v_noabi::document::view_or_value restrictions)
Restricts the contents of the documents based on information stored in the documents themselves.
pipeline & append_stage(bsoncxx::v_noabi::document::view_or_value stage)
Appends a stage to this pipeline object.
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 & graph_lookup(bsoncxx::v_noabi::document::view_or_value graph_lookup_args)
Performs a recursive search on a collection.
pipeline & project(bsoncxx::v_noabi::document::view_or_value projection)
Projects a subset of the fields in the documents to the next stage of the pipeline.
pipeline & current_op(bsoncxx::v_noabi::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 & coll_stats(bsoncxx::v_noabi::document::view_or_value coll_stats_args=bsoncxx::v_noabi::document::view{})
Returns statistics regarding a collection or view.
pipeline & lookup(bsoncxx::v_noabi::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 & 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 & add_fields(bsoncxx::v_noabi::document::view_or_value fields_to_add)
Adds new fields to documents.
pipeline & facet(bsoncxx::v_noabi::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::v_noabi::document::view_or_value replace_root_args)
Promotes a specified document to the top level and replaces all other fields.
pipeline & append_stages(bsoncxx::v_noabi::array::view_or_value stages)
Appends stages to this pipeline object from the given bson array.
pipeline & list_sessions(bsoncxx::v_noabi::document::view_or_value list_sessions_args)
Lists all sessions stored in the system.sessions collection in the config database.
bsoncxx::v_noabi::array::view view_array() const
pipeline & sort(bsoncxx::v_noabi::document::view_or_value ordering)
Sorts all input documents and returns them to the pipeline in sorted order.
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 & merge(bsoncxx::v_noabi::document::view_or_value merge_args)
Outputs the aggregation results to a collection.
pipeline & unwind(std::string field_name)
Deconstructs an array field from the input documents to output a document for each element.
pipeline & geo_near(bsoncxx::v_noabi::document::view_or_value geo_near_args)
Outputs documents in order of nearest to farthest from a specified point.
pipeline & bucket_auto(bsoncxx::v_noabi::document::view_or_value bucket_auto_args)
Categorizes documents into a specific number of groups, called buckets, based on a specified expressi...
pipeline & list_local_sessions(bsoncxx::v_noabi::document::view_or_value list_local_sessions_args)
Lists the sessions cached in memory by the mongod or mongos instance.
pipeline & index_stats()
Returns statistics regarding the use of each index for the collection.
pipeline & group(bsoncxx::v_noabi::document::view_or_value group_args)
Groups documents by some specified expression and outputs to the next stage a document for each disti...
pipeline & sort_by_count(bsoncxx::v_noabi::document::view_or_value field_expression)
Groups incoming documents based on the value of a specified expression, then computes the count of do...
pipeline & bucket(bsoncxx::v_noabi::document::view_or_value bucket_args)
Categorizes documents into groups, called buckets, based on a specified expression and bucket boundar...
pipeline & unwind(bsoncxx::v_noabi::document::view_or_value unwind_args)
Deconstructs an array field from the input documents to output a document for each element.
pipeline & out(std::string collection_name)
Takes documents returned by the aggregation pipeline and writes them to a specified collection.
The top-level namespace for bsoncxx library entities.
Definition: element-fwd.hpp:19
The top-level namespace for mongocxx library entities.
Definition: bulk_write-fwd.hpp:19