userver: userver/storages/mongo/bulk_ops.hpp Source File
Loading...
Searching...
No Matches
bulk_ops.hpp
Go to the documentation of this file.
1#pragma once
2
5
11
12USERVER_NAMESPACE_BEGIN
13
15class Bulk;
16} // namespace storages::mongo::operations
17
20
22class InsertOne {
23public:
24 explicit InsertOne(formats::bson::Document document);
25 ~InsertOne();
26
27 InsertOne(const InsertOne&);
28 InsertOne(InsertOne&&) noexcept;
29 InsertOne& operator=(const InsertOne&);
30 InsertOne& operator=(InsertOne&&) noexcept;
31
32 void SetOption() const {}
33
34private:
36
37 class Impl;
38 static constexpr std::size_t kSize =
40 .For64Bit(16)
41 .For32Bit(8);
42 static constexpr size_t kAlignment = alignof(void*);
44};
45
47class ReplaceOne {
48public:
49 ReplaceOne(formats::bson::Document selector, formats::bson::Document replacement);
50 ~ReplaceOne();
51
52 ReplaceOne(const ReplaceOne&);
53 ReplaceOne(ReplaceOne&&) noexcept;
54 ReplaceOne& operator=(const ReplaceOne&);
55 ReplaceOne& operator=(ReplaceOne&&) noexcept;
56
57 void SetOption(options::Upsert);
58
59private:
61
62 class Impl;
63 static constexpr std::size_t kSize =
65 .For64Bit(48)
66 .For32Bit(24);
67 static constexpr size_t kAlignment = alignof(void*);
69};
70
72class Update {
73public:
74 enum class Mode { kSingle, kMulti };
75
76 Update(Mode mode, formats::bson::Document selector, formats::bson::Document update);
77
82
83 ~Update();
84
85 Update(const Update&);
86 Update(Update&&) noexcept;
87 Update& operator=(const Update&);
88 Update& operator=(Update&&) noexcept;
89
90 void SetOption(options::Upsert);
91 void SetOption(const options::ArrayFilters&);
92
94 void SetOption(const options::Hint&);
95
96private:
97 friend class storages::mongo::operations::Bulk;
98
99 class Impl;
100 static constexpr std::size_t kSize =
101 compiler::SelectSize() //
102 .For64Bit(56)
103 .For32Bit(28);
104 static constexpr size_t kAlignment = alignof(void*);
105 utils::FastPimpl<Impl, kSize, kAlignment, utils::kStrictMatch> impl_;
106};
107
109class Delete {
110public:
111 enum class Mode { kSingle, kMulti };
112
113 Delete(Mode mode, formats::bson::Document selector);
114 ~Delete();
115
116 Delete(const Delete&);
117 Delete(Delete&&) noexcept;
118 Delete& operator=(const Delete&);
119 Delete& operator=(Delete&&) noexcept;
120
123
124private:
126
127 class Impl;
128 static constexpr std::size_t kSize =
130 .For64Bit(40)
131 .For32Bit(20);
132 static constexpr size_t kAlignment = alignof(void*);
134};
135
136} // namespace storages::mongo::bulk_ops
137
138USERVER_NAMESPACE_END