Loading...
Searching...
No Matches
mongocxx::bulk_write Class Reference

`#include <mongocxx/v_noabi/mongocxx/bulk_write.hpp>`

## Description

A batch of write operations that can be sent to the server as a group.

If you have a lot of write operations to execute, it can be more efficient to send them as part of a bulk_write in order to avoid unnecessary network-level round trips between the driver and the server.

Bulk writes affect a single collection only and are executed via the bulk_write::execute() method. Options that you would typically specify for individual write operations (such as write concern) are instead specified for the aggregate operation.

See also
  - https://www.mongodb.com/docs/manual/core/crud/
  - https://www.mongodb.com/docs/manual/core/bulk-write-operations/

## Public Member Functions

| bulk_write (bulk_write &&) noexcept=default
| Move constructs a bulk write operation.
| bulk_write (bulk_write const &other)=delete
| This class is not copyable.
| bulk_write (v1::bulk_write bulk)
| Construct with the mongocxx::v1 equivalent.
| ~bulk_write ()=default
| Destroys a bulk write operation.
bulk_write & | append (v_noabi::model::write const &operation)
| Appends a single write to the bulk write operation. The write operation's contents are copied into the bulk operation completely, so there is no dependency between the life of an appended write operation and the bulk operation itself.
bool | empty () const noexcept
| Checks if a bulk write operation is empty.
bsoncxx::v_noabi::stdx::optional< result::bulk_write > | execute () const
| Executes a bulk write.
| operator v1::bulk_write () &&
| Convert to the mongocxx::v1 equivalent.
| operator v1::bulk_write () const &=delete
| This class is not copyable.
bulk_write & | operator= (bulk_write &&) noexcept=default
| Move assigns a bulk write operation.
bulk_write & | operator= (bulk_write const &other)=delete
| This class is not copyable.

## Constructor & Destructor Documentation

## bulk_write() [1/3]

mongocxx::v_noabi::bulk_write::bulk_write | ( | bulk_write && |  | ) |

default noexcept

Move constructs a bulk write operation.

## bulk_write() [2/3]

mongocxx::v_noabi::bulk_write::bulk_write | ( | bulk_write const & | other | ) |

delete

This class is not copyable.

## bulk_write() [3/3]

mongocxx::v_noabi::bulk_write::bulk_write | ( | v1::bulk_write | bulk | ) |

inline

Construct with the mongocxx::v1 equivalent.

## ~bulk_write()

mongocxx::v_noabi::bulk_write::~bulk_write | ( |  | ) |

default

Destroys a bulk write operation.

## Member Function Documentation

## append()

bulk_write & mongocxx::v_noabi::bulk_write::append | ( | v_noabi::model::write const & | operation | ) |

Appends a single write to the bulk write operation. The write operation's contents are copied into the bulk operation completely, so there is no dependency between the life of an appended write operation and the bulk operation itself.

Parameters

  operation | The write operation to append (an instance of model::write)

A model::write can be implicitly constructed from any of the following MongoDB models:

- model::insert_one
- model::delete_one
- model::replace_one
- model::update_many
- model::update_one

Returns
  A reference to the object on which this member function is being called. This facilitates method chaining.

Exceptions

  mongocxx::v_noabi::logic_error | if the given operation is invalid.

## empty()

bool mongocxx::v_noabi::bulk_write::empty | ( |  | ) | const

inline noexcept

Checks if a bulk write operation is empty.

Returns
  A boolean indicating if the bulk write operation is empty.

## execute()

bsoncxx::v_noabi::stdx::optional< result::bulk_write > mongocxx::v_noabi::bulk_write::execute | ( |  | ) | const

Executes a bulk write.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | when there are errors processing the writes.

Returns
  The optional result of the bulk operation execution, a result::bulk_write.

See also
  - https://www.mongodb.com/docs/manual/core/bulk-write-operations/

## operator v1::bulk_write() [1/2]

mongocxx::v_noabi::bulk_write::operator v1::bulk_write | ( |  | ) | &&

inline explicit

Convert to the mongocxx::v1 equivalent.

Postconditions:
  - *this is in an assign-or-destroy-only state.

## operator v1::bulk_write() [2/2]

mongocxx::v_noabi::bulk_write::operator v1::bulk_write | ( |  | ) | const &

explicit delete

This class is not copyable.

## operator=() [1/2]

bulk_write & mongocxx::v_noabi::bulk_write::operator= | ( | bulk_write && |  | ) |

default noexcept

Move assigns a bulk write operation.

## operator=() [2/2]

bulk_write & mongocxx::v_noabi::bulk_write::operator= | ( | bulk_write const & | other | ) |

delete

This class is not copyable.

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

- mongocxx/v_noabi/mongocxx/bulk_write.hpp