MongoDB C++ Driver mongocxx-3.4.0
Loading...
Searching...
No Matches
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 <mongocxx/stdx.hpp>
23
24#include <mongocxx/config/prelude.hpp>
25
26namespace mongocxx {
27MONGOCXX_INLINE_NAMESPACE_BEGIN
28
29class client;
30class collection;
31class database;
32
33namespace options {
34
35class MONGOCXX_API change_stream {
36 public:
38
58
65 const bsoncxx::stdx::optional<bsoncxx::string::view_or_value>& full_document() const;
66
77 change_stream& batch_size(std::int32_t batch_size);
78
85 const stdx::optional<std::int32_t>& batch_size() const;
86
98
105 const stdx::optional<bsoncxx::document::view_or_value>& resume_after() const;
106
118
125 const stdx::optional<bsoncxx::document::view_or_value>& collation() const;
126
138 change_stream& max_await_time(std::chrono::milliseconds max_time);
139
146 const stdx::optional<std::chrono::milliseconds>& max_await_time() const;
147
160
161 private:
162 friend class ::mongocxx::client;
163 friend class ::mongocxx::collection;
164 friend class ::mongocxx::database;
165
166 bsoncxx::document::value as_bson() const;
167 stdx::optional<bsoncxx::string::view_or_value> _full_document;
168 stdx::optional<std::int32_t> _batch_size;
169 stdx::optional<bsoncxx::document::view_or_value> _collation;
170 stdx::optional<bsoncxx::document::view_or_value> _resume_after;
171 stdx::optional<std::chrono::milliseconds> _max_await_time;
172 // _start_at_operation_time is not wrapped in a stdx::optional because of a longstanding bug in
173 // the MNMLSTC polyfill that has been fixed on master, but not in the latest release:
174 // https://github.com/mnmlstc/core/pull/23
175 bsoncxx::types::b_timestamp _start_at_operation_time;
176 bool _start_at_operation_time_set = false;
177};
178} // namespace options
179MONGOCXX_INLINE_NAMESPACE_END
180} // namespace mongocxx
181
182#include <mongocxx/config/postlude.hpp>
A read-only BSON document that owns its underlying buffer.
Definition value.hpp:33
Class representing a view-or-value variant type for strings.
Definition view_or_value.hpp:36
Definition change_stream.hpp:35
const stdx::optional< std::chrono::milliseconds > & max_await_time() const
The current max_time setting.
change_stream & max_await_time(std::chrono::milliseconds max_time)
Sets the maximum amount of time for for the server to wait on new documents to satisfy a change strea...
const stdx::optional< bsoncxx::document::view_or_value > & collation() const
Retrieves the current collation for this operation.
change_stream & start_at_operation_time(bsoncxx::types::b_timestamp timestamp)
Specifies the logical starting point for the new change stream.
const stdx::optional< bsoncxx::document::view_or_value > & resume_after() const
Retrieves the current resumeToken for this change stream.
const bsoncxx::stdx::optional< bsoncxx::string::view_or_value > & full_document() const
Gets the current fullDocument setting.
change_stream & full_document(bsoncxx::string::view_or_value full_doc)
Sets the fullDocument stage for the $changeStream.
change_stream & batch_size(std::int32_t batch_size)
Sets the number of documents to return per batch.
change_stream & resume_after(bsoncxx::document::view_or_value resume_after)
Specifies the logical starting point for the new change stream.
const stdx::optional< std::int32_t > & batch_size() const
The current batch size setting.
change_stream & collation(bsoncxx::document::view_or_value collation)
Sets the collation for this operation.
Top level namespace for the MongoDB C++ driver.
Definition bulk_write.hpp:24
A BSON replication timestamp value.
Definition types.hpp:558