MongoDB C++ Driver  mongocxx-3.0.3
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 
95 
105 
115  pipeline& out(std::string collection_name);
116 
124  pipeline& project(bsoncxx::document::view_or_value projection);
125 
134  pipeline& redact(bsoncxx::document::view_or_value restrictions);
135 
144  pipeline& sample(std::int32_t size);
145 
154  pipeline& skip(std::int32_t skip);
155 
164 
174  pipeline& unwind(std::string field_name);
175 
179  bsoncxx::document::view view() const;
180 
181  private:
182  friend class collection;
183 
184  class MONGOCXX_PRIVATE impl;
185  std::unique_ptr<impl> _impl;
186 };
187 
188 MONGOCXX_INLINE_NAMESPACE_END
189 } // namespace mongocxx
190 
191 #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