MongoDB C++ Driver  mongocxx-3.4.0
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/document/view.hpp>
23 #include <bsoncxx/document/view_or_value.hpp>
24 
25 #include <mongocxx/config/prelude.hpp>
26 
27 namespace mongocxx {
28 MONGOCXX_INLINE_NAMESPACE_BEGIN
29 
30 class client;
31 class collection;
32 class database;
33 
37 class MONGOCXX_API pipeline {
38  public:
44  pipeline();
45 
49  pipeline(pipeline&&) noexcept;
50 
54  pipeline& operator=(pipeline&&) noexcept;
55 
59  ~pipeline();
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(
125 
138  pipeline& count(std::string field);
139 
154  pipeline& facet(bsoncxx::document::view_or_value facet_args);
155 
169  pipeline& geo_near(bsoncxx::document::view_or_value geo_near_args);
170 
184  pipeline& graph_lookup(bsoncxx::document::view_or_value graph_lookup_args);
185 
204  pipeline& group(bsoncxx::document::view_or_value group_args);
205 
215  pipeline& index_stats();
216 
229  pipeline& limit(std::int32_t limit);
230 
245  pipeline& lookup(bsoncxx::document::view_or_value lookup_args);
246 
261 
276  pipeline& out(std::string collection_name);
277 
290  pipeline& project(bsoncxx::document::view_or_value projection);
291 
305  pipeline& redact(bsoncxx::document::view_or_value restrictions);
306 
320  pipeline& replace_root(bsoncxx::document::view_or_value replace_root_args);
321 
335  pipeline& sample(std::int32_t size);
336 
350  pipeline& skip(std::int32_t docs_to_skip);
351 
365 
383  pipeline& sort_by_count(bsoncxx::document::view_or_value field_expression);
384 
403  pipeline& sort_by_count(std::string field_expression);
404 
423  pipeline& unwind(bsoncxx::document::view_or_value unwind_args);
424 
443  pipeline& unwind(std::string field_name);
444 
448  bsoncxx::array::view view_array() const;
449 
455  MONGOCXX_DEPRECATED bsoncxx::document::view view() const;
456  bsoncxx::document::view view_deprecated() const;
457 
458  private:
459  friend class client;
460  friend class collection;
461  friend class database;
462 
463  class MONGOCXX_PRIVATE impl;
464  std::unique_ptr<impl> _impl;
465 };
466 
467 MONGOCXX_INLINE_NAMESPACE_END
468 } // namespace mongocxx
469 
470 #include <mongocxx/config/postlude.hpp>
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
A read-only, non-owning view of a BSON document.
Definition: view.hpp:33
Class representing a client connection to MongoDB.
Definition: client.hpp:57
Class representing a MongoDB database.
Definition: database.hpp:44
A read-only, non-owning view of a BSON document.
Definition: view.hpp:33
Class representing a MongoDB aggregation pipeline.
Definition: pipeline.hpp:37
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:85