userver
C++ Async Framework
Loading...
Searching...
No Matches
write_result.hpp
1
#
pragma
once
2
3
#
include
<
cstddef
>
4
#
include
<
optional
>
5
#
include
<
unordered_map
>
6
#
include
<
vector
>
7
8
#
include
<
userver
/
formats
/
bson
/
document
.
hpp
>
9
#
include
<
userver
/
formats
/
bson
/
value
.
hpp
>
10
#
include
<
userver
/
storages
/
mongo
/
mongo_error
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
storages::mongo {
15
16
/// MongoDB write operation result
17
class
WriteResult
{
18
public
:
19
/// Creates an empty write result
20
WriteResult
() =
default
;
21
22
/// @cond
23
/// Wraps provided write result, internal use only
24
explicit
WriteResult(formats::
bson
::
Document
);
25
/// @endcond
26
27
/// @name Affected document counters
28
/// Valid only for acknowledged writes, i.e. non-zero write concern
29
/// @{
30
size_t InsertedCount()
const
;
31
size_t MatchedCount()
const
;
32
size_t ModifiedCount()
const
;
33
size_t UpsertedCount()
const
;
34
size_t DeletedCount()
const
;
35
/// @}
36
37
/// Map of `_id` values of upserted documents by operation (document) index
38
std
::
unordered_map
<
size_t
,
formats
::
bson
::
Value
>
UpsertedIds
()
const
;
39
40
/// The document returned by FindAnd* operation if any
41
std::optional<formats::
bson
::
Document
>
FoundDocument
()
const
;
42
43
/// @brief Map of server errors by operation (document) index.
44
///
45
/// For example, storages::mongo::Collection::InsertMany() with
46
/// storages::mongo::options::Unordered and
47
/// storages::mongo::options::SuppressServerExceptions option would produce a
48
/// WriteResult with WriteResult::ServerErrors() containing information about
49
/// failed insertions.
50
///
51
/// @see options::SuppressServerExceptions
52
std
::
unordered_map
<
size_t
,
MongoError
>
ServerErrors
()
const
;
53
54
/// @brief Write concern errors
55
/// @see options::SuppressServerExceptions
56
std
::
vector
<
MongoError
>
WriteConcernErrors
()
const
;
57
58
private
:
59
formats::
bson
::
Document
value_;
60
};
61
62
}
// namespace storages::mongo
63
64
USERVER_NAMESPACE_END
userver
storages
mongo
write_result.hpp
Generated on Tue Nov 19 2024 11:31:29 for userver by
Doxygen
1.10.0