MongoDB C++ Driver  mongocxx-3.0.1
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/document/view.hpp>
22 #include <bsoncxx/document/view_or_value.hpp>
23 
24 #include <mongocxx/config/prelude.hpp>
25 
26 namespace mongocxx {
27 MONGOCXX_INLINE_NAMESPACE_BEGIN
28 
29 class collection;
30 
34 class MONGOCXX_API pipeline {
35  public:
41  pipeline();
42 
46  pipeline(pipeline&&) noexcept;
47 
51  pipeline& operator=(pipeline&&) noexcept;
52 
56  ~pipeline();
57 
72 
80  pipeline& limit(std::int32_t limit);
81 
91 
101  pipeline& out(std::string collection_name);
102 
110  pipeline& project(bsoncxx::document::view_or_value projection);
111 
120  pipeline& redact(bsoncxx::document::view_or_value restrictions);
121 
130  pipeline& sample(std::int32_t size);
131 
140  pipeline& skip(std::int32_t skip);
141 
150 
160  pipeline& unwind(std::string field_name);
161 
165  bsoncxx::document::view view() const;
166 
167  private:
168  friend class collection;
169 
170  class MONGOCXX_PRIVATE impl;
171  std::unique_ptr<impl> _impl;
172 };
173 
174 MONGOCXX_INLINE_NAMESPACE_END
175 } // namespace mongocxx
176 
177 #include <mongocxx/config/postlude.hpp>
Definition: bulk_write.hpp:22
A read-only, non-owning view of a BSON document.
Definition: view.hpp:33
Class representing a MongoDB aggregation pipeline.
Definition: pipeline.hpp:34
Class representing server side document groupings within a MongoDB database.
Definition: collection.hpp:74