MongoDB C++ Driver  mongocxx-3.7.0
change_stream.hpp
1 // Copyright 2018-present 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 <chrono>
18 
19 #include <bsoncxx/document/view_or_value.hpp>
20 #include <bsoncxx/string/view_or_value.hpp>
21 #include <bsoncxx/types.hpp>
22 #include <bsoncxx/types/bson_value/view_or_value.hpp>
23 #include <mongocxx/stdx.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 
34 namespace options {
35 
39 class MONGOCXX_API change_stream {
40  public:
41  change_stream();
42 
70  change_stream& full_document(bsoncxx::string::view_or_value full_doc);
71 
78  const bsoncxx::stdx::optional<bsoncxx::string::view_or_value>& full_document() const;
79 
99  change_stream& full_document_before_change(
100  bsoncxx::string::view_or_value full_doc_before_change);
101 
108  const bsoncxx::stdx::optional<bsoncxx::string::view_or_value>& full_document_before_change()
109  const;
110 
121  change_stream& batch_size(std::int32_t batch_size);
122 
129  const stdx::optional<std::int32_t>& batch_size() const;
130 
142 
149  const stdx::optional<bsoncxx::types::bson_value::view_or_value>& comment() const;
150 
166  change_stream& resume_after(bsoncxx::document::view_or_value resume_after);
167 
174  const stdx::optional<bsoncxx::document::view_or_value>& resume_after() const;
175 
194 
201  const stdx::optional<bsoncxx::document::view_or_value>& start_after() const;
202 
213  change_stream& collation(bsoncxx::document::view_or_value collation);
214 
221  const stdx::optional<bsoncxx::document::view_or_value>& collation() const;
222 
234  change_stream& max_await_time(std::chrono::milliseconds max_time);
235 
242  const stdx::optional<std::chrono::milliseconds>& max_await_time() const;
243 
258  change_stream& start_at_operation_time(bsoncxx::types::b_timestamp timestamp);
259 
260  private:
261  friend class ::mongocxx::client;
262  friend class ::mongocxx::collection;
263  friend class ::mongocxx::database;
264 
265  bsoncxx::document::value as_bson() const;
266  stdx::optional<bsoncxx::string::view_or_value> _full_document;
267  stdx::optional<bsoncxx::string::view_or_value> _full_document_before_change;
268  stdx::optional<std::int32_t> _batch_size;
269  stdx::optional<bsoncxx::types::bson_value::view_or_value> _comment;
270  stdx::optional<bsoncxx::document::view_or_value> _collation;
271  stdx::optional<bsoncxx::document::view_or_value> _resume_after;
272  stdx::optional<bsoncxx::document::view_or_value> _start_after;
273  stdx::optional<std::chrono::milliseconds> _max_await_time;
274  // _start_at_operation_time is not wrapped in a stdx::optional because of a longstanding bug in
275  // the MNMLSTC polyfill that has been fixed on master, but not in the latest release:
276  // https://github.com/mnmlstc/core/pull/23
277  bsoncxx::types::b_timestamp _start_at_operation_time = {};
278  bool _start_at_operation_time_set = false;
279 };
280 } // namespace options
281 MONGOCXX_INLINE_NAMESPACE_END
282 } // namespace mongocxx
283 
284 #include <mongocxx/config/postlude.hpp>
mongocxx
Top level namespace for the MongoDB C++ driver.
Definition: bulk_write.hpp:24
bsoncxx::view_or_value
Class representing a view-or-value variant type.
Definition: view_or_value.hpp:30
bsoncxx::document::value
A read-only BSON document that owns its underlying buffer.
Definition: value.hpp:34
bsoncxx::string::view_or_value
Class representing a view-or-value variant type for strings.
Definition: view_or_value.hpp:36
bsoncxx::types::b_timestamp
A BSON replication timestamp value.
Definition: types.hpp:577
mongocxx::options::change_stream
Class representing MongoDB change stream options.
Definition: change_stream.hpp:39