userver: storages::mongo::WriteResult Class Reference
Loading...
Searching...
No Matches
storages::mongo::WriteResult Class Reference

#include <userver/storages/mongo/write_result.hpp>

Detailed Description

MongoDB write operation result.

Definition at line 20 of file write_result.hpp.

Public Member Functions

 WriteResult ()=default
 Creates an empty write result.
 
std::unordered_map< size_t, formats::bson::ValueUpsertedIds () const
 Map of _id values of upserted documents by operation (document) index.
 
std::optional< formats::bson::DocumentFoundDocument () const
 The document returned by FindAnd* operation if any.
 
std::unordered_map< size_t, MongoErrorServerErrors () const
 Map of server errors by operation (document) index.
 
std::vector< MongoErrorWriteConcernErrors () const
 Write concern errors.
 
const MongoErrorOperationError () const
 If the operation is not completed successfully, an error that caused it will be returned.
 
Affected document counters

Valid only for acknowledged writes, i.e. non-zero write concern

size_t InsertedCount () const
 
size_t MatchedCount () const
 
size_t ModifiedCount () const
 
size_t UpsertedCount () const
 
size_t DeletedCount () const
 

Member Function Documentation

◆ OperationError()

const MongoError & storages::mongo::WriteResult::OperationError ( ) const

If the operation is not completed successfully, an error that caused it will be returned.

It is necessary to check whether an error is set up.

See also
options::SuppressServerExceptions

◆ ServerErrors()

std::unordered_map< size_t, MongoError > storages::mongo::WriteResult::ServerErrors ( ) const

Map of server errors by operation (document) index.

For example, storages::mongo::Collection::InsertMany() with storages::mongo::options::Unordered and storages::mongo::options::SuppressServerExceptions option would produce a WriteResult with WriteResult::ServerErrors() containing information about failed insertions.

See also
options::SuppressServerExceptions

◆ WriteConcernErrors()

std::vector< MongoError > storages::mongo::WriteResult::WriteConcernErrors ( ) const

Write concern errors.

See also
options::SuppressServerExceptions

The documentation for this class was generated from the following file: