MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
Public Member Functions | List of all members
mongo::WriteResult Class Reference

Class representing the result of a write operations sent to the server. More...

#include <write_result.h>

Public Member Functions

 WriteResult ()
 Creates an empty write result.
 
bool hasErrors () const
 Returns true if there have been write errors of any kind.
 
bool hasWriteErrors () const
 Returns true if there have been write errors.
 
bool hasWriteConcernErrors () const
 Returns true if there have been write concern errors.
 
bool hasModifiedCount () const
 Returns true if the number of modified documents is available.
 
int nInserted () const
 The number of documents that were inserted.
 
int nUpserted () const
 The number of documents that were upserted.
 
int nMatched () const
 The number of documents that were matched.
 
int nModified () const
 The number of documents that were modified.
 
int nRemoved () const
 The number of documents that were removed.
 
const std::vector< BSONObj > & upserted () const
 The information about documents that were upserted.
 
const std::vector< BSONObj > & writeErrors () const
 Vector with the write errors that occurred.
 
const std::vector< BSONObj > & writeConcernErrors () const
 Vector with the write concern errors that occurred.
 

Detailed Description

Class representing the result of a write operations sent to the server.

Member Function Documentation

◆ hasErrors()

bool mongo::WriteResult::hasErrors ( ) const

Returns true if there have been write errors of any kind.

This includes write errors and write concern errors.

◆ hasModifiedCount()

bool mongo::WriteResult::hasModifiedCount ( ) const

Returns true if the number of modified documents is available.

This will not be true if any write response comes from a node running MongoDB <2.6.

Note: You can only call nModified() if hasModifiedCount() is true.

◆ hasWriteConcernErrors()

bool mongo::WriteResult::hasWriteConcernErrors ( ) const

Returns true if there have been write concern errors.

This class of error can occur after the execution of writes on the server if they cannot be fully persisted or replicated to fulfill given supplied level of write concern.

◆ hasWriteErrors()

bool mongo::WriteResult::hasWriteErrors ( ) const

Returns true if there have been write errors.

These include duplicate key errors, etc... that are possibly encountered in the process of write execution on the server.

◆ nInserted()

int mongo::WriteResult::nInserted ( ) const

The number of documents that were inserted.

Note: This field is always available.

◆ nMatched()

int mongo::WriteResult::nMatched ( ) const

The number of documents that were matched.

Note: This field is always available.

◆ nModified()

int mongo::WriteResult::nModified ( ) const

The number of documents that were modified.

Warning: This field is only available if hasModifiedCount() is true.

◆ nRemoved()

int mongo::WriteResult::nRemoved ( ) const

The number of documents that were removed.

Note: This field is always available.

◆ nUpserted()

int mongo::WriteResult::nUpserted ( ) const

The number of documents that were upserted.

Note: This field is always available.

◆ upserted()

const std::vector< BSONObj > & mongo::WriteResult::upserted ( ) const

The information about documents that were upserted.

Note: The objects in the vector have an "index" and "_id" field.


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