userver
C++ Async Framework
Loading...
Searching...
No Matches
bulk_ops.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/mongo/bulk_ops.hpp
4
/// @brief Bulk sub-operation models
5
6
#
include
<
userver
/
compiler
/
select
.
hpp
>
7
#
include
<
userver
/
formats
/
bson
/
document
.
hpp
>
8
#
include
<
userver
/
storages
/
mongo
/
options
.
hpp
>
9
#
include
<
userver
/
utils
/
fast_pimpl
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
storages::mongo::
operations
{
14
class
Bulk
;
15
}
// namespace storages::mongo::operations
16
17
/// Bulk sub-operations
18
namespace
storages::mongo::
bulk_ops
{
19
20
/// Inserts a single document as part of bulk operation
21
class
InsertOne
{
22
public
:
23
explicit
InsertOne(
formats
::
bson
::
Document
document);
24
~InsertOne();
25
26
InsertOne(
const
InsertOne
&);
27
InsertOne(
InsertOne
&&)
noexcept
;
28
InsertOne
& operator=(
const
InsertOne
&);
29
InsertOne
& operator=(
InsertOne
&&)
noexcept
;
30
31
void
SetOption()
const
{}
32
33
private
:
34
friend
class
storages::mongo::
operations
::
Bulk
;
35
36
class
Impl;
37
static
constexpr
std::size_t kSize =
38
compiler
::SelectSize()
//
39
.For64Bit(16)
40
.For32Bit(8);
41
static
constexpr
size_t kAlignment =
alignof
(
void
*);
42
utils::FastPimpl<Impl, kSize, kAlignment, utils
::
kStrictMatch
> impl_;
43
};
44
45
/// Replaces a single document as part of bulk operation
46
class
ReplaceOne
{
47
public
:
48
ReplaceOne(
formats
::
bson
::
Document
selector,
formats
::
bson
::
Document
replacement);
49
~ReplaceOne();
50
51
ReplaceOne(
const
ReplaceOne
&);
52
ReplaceOne(
ReplaceOne
&&)
noexcept
;
53
ReplaceOne
& operator=(
const
ReplaceOne
&);
54
ReplaceOne
& operator=(
ReplaceOne
&&)
noexcept
;
55
56
void
SetOption(
options
::
Upsert
);
57
58
private
:
59
friend
class
storages::mongo::
operations
::
Bulk
;
60
61
class
Impl;
62
static
constexpr
std::size_t kSize =
63
compiler
::SelectSize()
//
64
.For64Bit(48)
65
.For32Bit(24);
66
static
constexpr
size_t kAlignment =
alignof
(
void
*);
67
utils::FastPimpl<Impl, kSize, kAlignment, utils
::
kStrictMatch
> impl_;
68
};
69
70
/// Updates documents as part of bulk operation
71
class
Update
{
72
public
:
73
enum
class
Mode { kSingle, kMulti };
74
75
Update(Mode mode,
formats
::
bson
::
Document
selector,
formats
::
bson
::
Document
update);
76
~Update();
77
78
Update(
const
Update
&);
79
Update(
Update
&&)
noexcept
;
80
Update
& operator=(
const
Update
&);
81
Update
& operator=(
Update
&&)
noexcept
;
82
83
void
SetOption(
options
::
Upsert
);
84
void
SetOption(
const
options
::
ArrayFilters
&);
85
86
/// @note Available starting in MongoDB 4.2
87
void
SetOption
(
const
options
::
Hint
&);
88
89
private
:
90
friend
class
storages::mongo::
operations
::
Bulk
;
91
92
class
Impl;
93
static
constexpr
std::size_t kSize =
94
compiler
::SelectSize()
//
95
.For64Bit(56)
96
.For32Bit(28);
97
static
constexpr
size_t kAlignment =
alignof
(
void
*);
98
utils::FastPimpl<Impl, kSize, kAlignment, utils
::
kStrictMatch
> impl_;
99
};
100
101
/// Deletes documents as part of bulk operation
102
class
Delete
{
103
public
:
104
enum
class
Mode { kSingle, kMulti };
105
106
Delete(Mode mode,
formats
::
bson
::
Document
selector);
107
~Delete();
108
109
Delete(
const
Delete
&);
110
Delete(
Delete
&&)
noexcept
;
111
Delete
& operator=(
const
Delete
&);
112
Delete
& operator=(
Delete
&&)
noexcept
;
113
114
/// @note Available starting in MongoDB 4.2
115
void
SetOption
(
const
options
::
Hint
&);
116
117
private
:
118
friend
class
storages::mongo::
operations
::
Bulk
;
119
120
class
Impl;
121
static
constexpr
std::size_t kSize =
122
compiler
::SelectSize()
//
123
.For64Bit(40)
124
.For32Bit(20);
125
static
constexpr
size_t kAlignment =
alignof
(
void
*);
126
utils::FastPimpl<Impl, kSize, kAlignment, utils
::
kStrictMatch
> impl_;
127
};
128
129
}
// namespace storages::mongo::bulk_ops
130
131
USERVER_NAMESPACE_END
userver
storages
mongo
bulk_ops.hpp
Generated on Fri Dec 5 2025 12:22:38 for userver by
Doxygen
1.13.2