Loading...
Searching...
No Matches
mongocxx::v_noabi::collection Class Reference

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

## Description

A MongoDB collection.

Collections do not require or enforce a schema and documents inside of a collection can have different fields. While not a requirement, typically documents in a collection have a similar shape or related purpose.

Example
  // Connect and get a collection.
  mongocxx::v_noabi::client mongo_client{mongocxx::v_noabi::uri{}};
  auto coll = mongo_client["database"]["collection"];
  mongocxx::v_noabi::client
  A client connection to a MongoDB server.
  Definition client.hpp:77
  mongocxx::v_noabi::uri
  A MongoDB connection string URI.
  Definition uri.hpp:55

## Public Member Functions

| collection () noexcept
| Default constructs a collection object. The collection is equivalent to the state of a moved from collection. The only valid actions to take with a default constructed collection are to assign to it, or destroy it.
| collection (collection &&other) noexcept=default
| Move constructs a collection.
| collection (collection const &other)
| Copy constructs a collection.
| collection (v1::collection collection)
| Construct with the mongocxx::v1 equivalent.
| ~collection ()=default
| Destroys a collection.
v_noabi::cursor | aggregate (v_noabi::client_session const &session, v_noabi::pipeline const &pipeline, v_noabi::options::aggregate const &options={})
| Runs an aggregation framework pipeline against this collection.
v_noabi::cursor | aggregate (v_noabi::pipeline const &pipeline, v_noabi::options::aggregate const &options={})
| Runs an aggregation framework pipeline against this collection.
template<typename container_type>
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > | bulk_write (container_type const &writes, v_noabi::options::bulk_write const &options={})
| Sends a container of writes to the server as a bulk write operation.
template<typename container_type>
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > | bulk_write (v_noabi::client_session const &session, container_type const &writes, v_noabi::options::bulk_write const &options={})
| Sends a container of writes to the server as a bulk write operation.
template<typename write_model_iterator_type>
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > | bulk_write (v_noabi::client_session const &session, write_model_iterator_type begin, write_model_iterator_type end, v_noabi::options::bulk_write const &options={})
| Sends writes starting at `begin` and ending at `end` to the server as a bulk write operation.
template<typename write_model_iterator_type>
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > | bulk_write (write_model_iterator_type begin, write_model_iterator_type end, v_noabi::options::bulk_write const &options={})
| Sends writes starting at `begin` and ending at `end` to the server as a bulk write operation.
std::int64_t | count_documents (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::count const &options={})
| Counts the number of documents matching the provided filter.
std::int64_t | count_documents (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::count const &options={})
| Counts the number of documents matching the provided filter.
v_noabi::bulk_write | create_bulk_write (v_noabi::client_session const &session, v_noabi::options::bulk_write const &options={})
| Creates a new bulk operation to be executed against this collection. The lifetime of the bulk_write is independent of the collection.
v_noabi::bulk_write | create_bulk_write (v_noabi::options::bulk_write const &options={})
| Creates a new bulk operation to be executed against this collection. The lifetime of the bulk_write is independent of the collection.
bsoncxx::v_noabi::document::value | create_index (bsoncxx::v_noabi::document::view_or_value keys, bsoncxx::v_noabi::document::view_or_value index_options={}, v_noabi::options::index_view operation_options={})
| Creates an index over the collection for the provided keys with the provided options.
bsoncxx::v_noabi::document::value | create_index (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value keys, bsoncxx::v_noabi::document::view_or_value index_options={}, v_noabi::options::index_view operation_options={})
| Creates an index over the collection for the provided keys with the provided options.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > | delete_many (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::delete_options const &options={})
| Deletes all matching documents from the collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > | delete_many (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::delete_options const &options={})
| Deletes all matching documents from the collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > | delete_one (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::delete_options const &options={})
| Deletes a single matching document from the collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > | delete_one (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::delete_options const &options={})
| Deletes a single matching document from the collection.
v_noabi::cursor | distinct (bsoncxx::v_noabi::string::view_or_value name, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::distinct const &options={})
| Finds the distinct values for a specified field across the collection.
v_noabi::cursor | distinct (v_noabi::client_session const &session, bsoncxx::v_noabi::string::view_or_value name, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::distinct const &options={})
| Finds the distinct values for a specified field across the collection.
void | drop (bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const &write_concern={}, bsoncxx::v_noabi::document::view_or_value collection_options={})
| Drops this collection and all its contained documents from the database.
void | drop (v_noabi::client_session const &session, bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const &write_concern={}, bsoncxx::v_noabi::document::view_or_value collection_options={})
| Drops this collection and all its contained documents from the database.
std::int64_t | estimated_document_count (v_noabi::options::estimated_document_count const &options={})
| Returns an estimate of the number of documents in the collection.
v_noabi::cursor | find (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const &options={})
| Finds the documents in this collection which match the provided filter.
v_noabi::cursor | find (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const &options={})
| Finds the documents in this collection which match the provided filter.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const &options={})
| Finds a single document in this collection that match the provided filter.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find const &options={})
| Finds a single document in this collection that match the provided filter.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_delete (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find_one_and_delete const &options={})
| Finds a single document matching the filter, deletes it, and returns the original.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_delete (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::options::find_one_and_delete const &options={})
| Finds a single document matching the filter, deletes it, and returns the original.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_replace (bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement, v_noabi::options::find_one_and_replace const &options={})
| Finds a single document matching the filter, replaces it, and returns either the original or the replacement document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_replace (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement, v_noabi::options::find_one_and_replace const &options={})
| Finds a single document matching the filter, replaces it, and returns either the original or the replacement document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_update (bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::find_one_and_update const &options={})
| Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_update (bsoncxx::v_noabi::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, v_noabi::options::find_one_and_update const &options={})
| Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_update (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::pipeline const &update, v_noabi::options::find_one_and_update const &options={})
| Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_update (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::find_one_and_update const &options={})
| Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_update (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, v_noabi::options::find_one_and_update const &options={})
| Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > | find_one_and_update (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::pipeline const &update, v_noabi::options::find_one_and_update const &options={})
| Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.
v_noabi::index_view | indexes ()
| Gets an index_view to the collection.
template<typename container_type>
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > | insert_many (container_type const &container, v_noabi::options::insert const &options={})
| Inserts multiple documents into the collection. If any of the documents are missing identifiers the driver will generate them.
template<typename document_view_iterator_type>
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > | insert_many (document_view_iterator_type begin, document_view_iterator_type end, v_noabi::options::insert const &options={})
| Inserts multiple documents into the collection. If any of the documents are missing identifiers the driver will generate them.
template<typename container_type>
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > | insert_many (v_noabi::client_session const &session, container_type const &container, v_noabi::options::insert const &options={})
| Inserts multiple documents into the collection. If any of the documents are missing identifiers the driver will generate them.
template<typename document_view_iterator_type>
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > | insert_many (v_noabi::client_session const &session, document_view_iterator_type begin, document_view_iterator_type end, v_noabi::options::insert const &options={})
| Inserts multiple documents into the collection. If any of the documents are missing identifiers the driver will generate them.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_one > | insert_one (bsoncxx::v_noabi::document::view_or_value document, v_noabi::options::insert const &options={})
| Inserts a single document into the collection. If the document is missing an identifier (`_id` field) one will be generated for it.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_one > | insert_one (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value document, v_noabi::options::insert const &options={})
| Inserts a single document into the collection. If the document is missing an identifier (`_id` field) one will be generated for it.
v_noabi::cursor | list_indexes () const
| Returns a list of the indexes currently on this collection.
v_noabi::cursor | list_indexes (v_noabi::client_session const &session) const
| Returns a list of the indexes currently on this collection.
bsoncxx::v_noabi::stdx::string_view | name () const
| Returns the name of this collection.
| operator bool () const noexcept
| Returns true if the collection is valid, meaning it was not default constructed or moved from.
| operator v1::collection () &&
| Convert to the mongocxx::v1 equivalent.
| operator v1::collection () const &
| Convert to the mongocxx::v1 equivalent.
collection & | operator= (collection &&other) noexcept=default
| Move assigns a collection.
collection & | operator= (collection const &other)
| Copy assigns a collection.
v_noabi::read_concern | read_concern () const
| Gets the read_concern for the collection.
void | read_concern (v_noabi::read_concern rc)
| Sets the read_concern for this collection. Changes will not have any effect on existing cursors or other read operations which use the previously-set read concern.
v_noabi::read_preference | read_preference () const
| Gets the read_preference for the collection.
void | read_preference (v_noabi::read_preference rp)
| Sets the read_preference for this collection. Changes will not have any effect on existing cursors or other read operations which use the read preference.
void | rename (bsoncxx::v_noabi::string::view_or_value new_name, bool drop_target_before_rename=false, bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const &write_concern={})
| Rename this collection.
void | rename (v_noabi::client_session const &session, bsoncxx::v_noabi::string::view_or_value new_name, bool drop_target_before_rename=false, bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const &write_concern={})
| Rename this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::replace_one > | replace_one (bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement, v_noabi::options::replace const &options={})
| Replaces a single document matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::replace_one > | replace_one (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement, v_noabi::options::replace const &options={})
| Replaces a single document matching the provided filter in this collection.
v_noabi::search_index_view | search_indexes ()
| Gets a search_index_view to the collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_many (bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::update const &options={})
| Updates multiple documents matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_many (bsoncxx::v_noabi::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, v_noabi::options::update const &options={})
| Updates multiple documents matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_many (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::pipeline const &update, v_noabi::options::update const &options={})
| Updates multiple documents matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_many (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::update const &options={})
| Updates multiple documents matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_many (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, v_noabi::options::update const &options={})
| Updates multiple documents matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_many (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::pipeline const &update, v_noabi::options::update const &options={})
| Updates multiple documents matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_one (bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::update const &options={})
| Updates a single document matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_one (bsoncxx::v_noabi::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, v_noabi::options::update const &options={})
| Updates a single document matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_one (bsoncxx::v_noabi::document::view_or_value filter, v_noabi::pipeline const &update, v_noabi::options::update const &options={})
| Updates a single document matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_one (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value update, v_noabi::options::update const &options={})
| Updates a single document matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_one (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, std::initializer_list< _empty_doc_tag > update, v_noabi::options::update const &options={})
| Updates a single document matching the provided filter in this collection.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > | update_one (v_noabi::client_session const &session, bsoncxx::v_noabi::document::view_or_value filter, v_noabi::pipeline const &update, v_noabi::options::update const &options={})
| Updates a single document matching the provided filter in this collection.
v_noabi::change_stream | watch (v_noabi::client_session const &session, v_noabi::options::change_stream const &options={})
v_noabi::change_stream | watch (v_noabi::client_session const &session, v_noabi::pipeline const &pipe, v_noabi::options::change_stream const &options={})
| Gets a change stream on this collection.
v_noabi::change_stream | watch (v_noabi::options::change_stream const &options={})
| Gets a change stream on this collection with an empty pipeline. Change streams are only supported with a "majority" read concern or no read concern.
v_noabi::change_stream | watch (v_noabi::pipeline const &pipe, v_noabi::options::change_stream const &options={})
| Gets a change stream on this collection. Change streams are only supported with a "majority" read concern or no read concern.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > | write (v_noabi::client_session const &session, v_noabi::model::write const &write, v_noabi::options::bulk_write const &options={})
| Sends a write to the server as a bulk write operation.
bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > | write (v_noabi::model::write const &write, v_noabi::options::bulk_write const &options={})
| Sends a write to the server as a bulk write operation.
v_noabi::write_concern | write_concern () const
| Gets the write_concern for the collection.
void | write_concern (v_noabi::write_concern wc)
| Sets the write_concern for this collection. Changes will not have any effect on existing write operations.

## Constructor & Destructor Documentation

## collection() [1/4]

mongocxx::v_noabi::collection::collection | ( |  | ) |

inline noexcept

Default constructs a collection object. The collection is equivalent to the state of a moved from collection. The only valid actions to take with a default constructed collection are to assign to it, or destroy it.

## collection() [2/4]

mongocxx::v_noabi::collection::collection | ( | collection && | other | ) |

default noexcept

Move constructs a collection.

## collection() [3/4]

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

Copy constructs a collection.

## ~collection()

mongocxx::v_noabi::collection::~collection | ( |  | ) |

default

Destroys a collection.

## collection() [4/4]

mongocxx::v_noabi::collection::collection | ( | v1::collection | collection | ) |

inline

Construct with the mongocxx::v1 equivalent.

## Member Function Documentation

## aggregate() [1/2]

v_noabi::cursor mongocxx::v_noabi::collection::aggregate | ( | v_noabi::client_session const & | session,
|  | v_noabi::pipeline const & | pipeline,
|  | v_noabi::options::aggregate const & | options = {} )

Runs an aggregation framework pipeline against this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the aggregation.
  pipeline | The pipeline of aggregation operations to perform.
  options | Optional arguments, see mongocxx::v_noabi::options::aggregate.

Returns
  A mongocxx::v_noabi::cursor with the results. If the query fails, the cursor throws mongocxx::v_noabi::query_exception when the returned cursor is iterated.

See also
  - https://www.mongodb.com/docs/manual/reference/command/aggregate/

Note
  In order to pass a read concern to this, you must use the collection level set read concern - collection::read_concern(rc). (Write concern supported only for MongoDB 3.4+).

## aggregate() [2/2]

v_noabi::cursor mongocxx::v_noabi::collection::aggregate | ( | v_noabi::pipeline const & | pipeline,
|  | v_noabi::options::aggregate const & | options = {} )

Runs an aggregation framework pipeline against this collection.

Parameters

  pipeline | The pipeline of aggregation operations to perform.
  options | Optional arguments, see mongocxx::v_noabi::options::aggregate.

Returns
  A mongocxx::v_noabi::cursor with the results. If the query fails, the cursor throws mongocxx::v_noabi::query_exception when the returned cursor is iterated.

See also
  - https://www.mongodb.com/docs/manual/reference/command/aggregate/

Note
  In order to pass a read concern to this, you must use the collection level set read concern - collection::read_concern(rc). (Write concern supported only for MongoDB 3.4+).

## bulk_write() [1/4]

template<typename container_type>

bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > mongocxx::v_noabi::collection::bulk_write | ( | container_type const & | writes,
|  | v_noabi::options::bulk_write const & | options = {} )

inline

Sends a container of writes to the server as a bulk write operation.

Template Parameters

  container_type | The container type. Must meet the requirements for the container concept with a value type of model::write.

Parameters

  writes | A container of model::write.
  options | Optional arguments, see v_noabi::options::bulk_write.

Returns
  The optional result of the bulk operation execution. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

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

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

## bulk_write() [2/4]

template<typename container_type>

bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > mongocxx::v_noabi::collection::bulk_write | ( | v_noabi::client_session const & | session,
|  | container_type const & | writes,
|  | v_noabi::options::bulk_write const & | options = {} )

inline

Sends a container of writes to the server as a bulk write operation.

Template Parameters

  container_type | The container type. Must meet the requirements for the container concept with a value type of model::write.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the bulk operation.
  writes | A container of model::write.
  options | Optional arguments, see v_noabi::options::bulk_write.

Returns
  The optional result of the bulk operation execution. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

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

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

## bulk_write() [3/4]

template<typename write_model_iterator_type>

bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > mongocxx::v_noabi::collection::bulk_write | ( | v_noabi::client_session const & | session,
|  | write_model_iterator_type | begin,
|  | write_model_iterator_type | end,
|  | v_noabi::options::bulk_write const & | options = {} )

inline

Sends writes starting at `begin` and ending at `end` to the server as a bulk write operation.

Template Parameters

  write_model_iterator_type | The container type. Must meet the requirements for the input iterator concept with a value type of model::write.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the bulk operation.
  begin | Iterator pointing to the first model::write to send.
  end | Iterator pointing to the end of the writes to send.
  options | Optional arguments, see v_noabi::options::bulk_write.

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

Exceptions

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

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

## bulk_write() [4/4]

template<typename write_model_iterator_type>

bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > mongocxx::v_noabi::collection::bulk_write | ( | write_model_iterator_type | begin,
|  | write_model_iterator_type | end,
|  | v_noabi::options::bulk_write const & | options = {} )

inline

Sends writes starting at `begin` and ending at `end` to the server as a bulk write operation.

Template Parameters

  write_model_iterator_type | The container type. Must meet the requirements for the input iterator concept with a value type of model::write.

Parameters

  begin | Iterator pointing to the first model::write to send.
  end | Iterator pointing to the end of the writes to send.
  options | Optional arguments, see v_noabi::options::bulk_write.

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

Exceptions

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

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

## count_documents() [1/2]

std::int64_t mongocxx::v_noabi::collection::count_documents | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::count const & | options = {} )

Counts the number of documents matching the provided filter.

Parameters

  filter | The filter that documents must match in order to be counted.
  options | Optional arguments, see mongocxx::v_noabi::options::count.

Returns
  The count of the documents that matched the filter.

Exceptions

  mongocxx::v_noabi::query_exception | if the count operation fails.

Note
  For a fast count of the total documents in a collection, see estimated_document_count().
  Due to an oversight in MongoDB server versions 5.0.0 through 5.0.7, the count command was not included in Stable API v1. Users of the Stable API with estimatedDocumentCount are recommended to upgrade their server version to 5.0.8 or newer, or set apiStrict: false to avoid encountering errors.

See also
  - mongocxx::v_noabi::collection::estimated_document_count

## count_documents() [2/2]

std::int64_t mongocxx::v_noabi::collection::count_documents | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::count const & | options = {} )

Counts the number of documents matching the provided filter.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the count.
  filter | The filter that documents must match in order to be counted.
  options | Optional arguments, see mongocxx::v_noabi::options::count.

Returns
  The count of the documents that matched the filter.

Exceptions

  mongocxx::v_noabi::query_exception | if the count operation fails.

Note
  Due to an oversight in MongoDB server versions 5.0.0 through 5.0.7, the count command was not included in Stable API v1. Users of the Stable API with estimatedDocumentCount are recommended to upgrade their server version to 5.0.8 or newer, or set apiStrict: false to avoid encountering errors.

See also
  - mongocxx::v_noabi::collection::estimated_document_count

## create_bulk_write() [1/2]

v_noabi::bulk_write mongocxx::v_noabi::collection::create_bulk_write | ( | v_noabi::client_session const & | session,
|  | v_noabi::options::bulk_write const & | options = {} )

Creates a new bulk operation to be executed against this collection. The lifetime of the bulk_write is independent of the collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the bulk operation.
  options | Optional arguments; see mongocxx::v_noabi::options::bulk_write.

Returns
  The newly-created bulk write.

## create_bulk_write() [2/2]

v_noabi::bulk_write mongocxx::v_noabi::collection::create_bulk_write | ( | v_noabi::options::bulk_write const & | options = {} | ) |

Creates a new bulk operation to be executed against this collection. The lifetime of the bulk_write is independent of the collection.

Parameters

  options | Optional arguments; see mongocxx::v_noabi::options::bulk_write.

Returns
  The newly-created bulk write.

## create_index() [1/2]

bsoncxx::v_noabi::document::value mongocxx::v_noabi::collection::create_index | ( | bsoncxx::v_noabi::document::view_or_value | keys,
|  | bsoncxx::v_noabi::document::view_or_value | index_options = {},
|  | v_noabi::options::index_view | operation_options = {} )

inline

Creates an index over the collection for the provided keys with the provided options.

Parameters

  keys | The keys for the index: `{a:` 1, b: -1}
  index_options | A document containing optional arguments for creating the index.
  operation_options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  mongocxx::v_noabi::operation_exception | if index creation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/createIndexes/

Note
  Write concern supported only for MongoDB 3.4+.

## create_index() [2/2]

bsoncxx::v_noabi::document::value mongocxx::v_noabi::collection::create_index | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | keys,
|  | bsoncxx::v_noabi::document::view_or_value | index_options = {},
|  | v_noabi::options::index_view | operation_options = {} )

inline

Creates an index over the collection for the provided keys with the provided options.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the index creation.
  keys | The keys for the index: `{a:` 1, b: -1}
  index_options | A document containing optional arguments for creating the index.
  operation_options | Optional arguments for the overall operation, see mongocxx::v_noabi::options::index_view.

Exceptions

  mongocxx::v_noabi::operation_exception | if index creation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/createIndexes/

Note
  Write concern supported only for MongoDB 3.4+.

## delete_many() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > mongocxx::v_noabi::collection::delete_many | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::delete_options const & | options = {} )

Deletes all matching documents from the collection.

Parameters

  filter | Document view representing the data to be deleted.
  options | Optional arguments, see mongocxx::v_noabi::options::delete_options.

Returns
  The optional result of performing the deletion. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | if the delete fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/delete/

## delete_many() [2/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > mongocxx::v_noabi::collection::delete_many | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::delete_options const & | options = {} )

Deletes all matching documents from the collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the deletion.
  filter | Document view representing the data to be deleted.
  options | Optional arguments, see mongocxx::v_noabi::options::delete_options.

Returns
  The optional result of performing the deletion. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | if the delete fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/delete/

## delete_one() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > mongocxx::v_noabi::collection::delete_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::delete_options const & | options = {} )

Deletes a single matching document from the collection.

Parameters

  filter | Document view representing the data to be deleted.
  options | Optional arguments, see mongocxx::v_noabi::options::delete_options.

Returns
  The optional result of performing the deletion. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | if the delete fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/delete/

## delete_one() [2/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::delete_result > mongocxx::v_noabi::collection::delete_one | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::delete_options const & | options = {} )

Deletes a single matching document from the collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the deletion.
  filter | Document view representing the data to be deleted.
  options | Optional arguments, see mongocxx::v_noabi::options::delete_options.

Returns
  The optional result of performing the deletion. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | if the delete fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/delete/

## distinct() [1/2]

v_noabi::cursor mongocxx::v_noabi::collection::distinct | ( | bsoncxx::v_noabi::string::view_or_value | name,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::distinct const & | options = {} )

Finds the distinct values for a specified field across the collection.

Parameters

  name | The field for which the distinct values will be found.
  filter | Document view representing the documents for which the distinct operation will apply.
  options | Optional arguments, see v_noabi::options::distinct.

Returns
  mongocxx::v_noabi::cursor having the distinct values for the specified field. If the operation fails, the cursor throws mongocxx::v_noabi::query_exception when the returned cursor is iterated.

See also
  - https://www.mongodb.com/docs/manual/reference/command/distinct/

## distinct() [2/2]

v_noabi::cursor mongocxx::v_noabi::collection::distinct | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::string::view_or_value | name,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::distinct const & | options = {} )

Finds the distinct values for a specified field across the collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  name | The field for which the distinct values will be found.
  filter | Document view representing the documents for which the distinct operation will apply.
  options | Optional arguments, see v_noabi::options::distinct.

Returns
  mongocxx::v_noabi::cursor having the distinct values for the specified field. If the operation fails, the cursor throws mongocxx::v_noabi::query_exception when the returned cursor is iterated.

See also
  - https://www.mongodb.com/docs/manual/reference/command/distinct/

## drop() [1/2]

void mongocxx::v_noabi::collection::drop | ( | bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & | write_concern = {},
|  | bsoncxx::v_noabi::document::view_or_value | collection_options = {} )

Drops this collection and all its contained documents from the database.

Parameters

  write_concern | (optional) The write concern to use for this operation. Defaults to the collection wide write concern if none is provided.
  collection_options | (optional) Collection options to use for this operation.

Exceptions

  mongocxx::v_noabi::operation_exception | if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/drop/

Note
  Write concern supported only for MongoDB 3.4+.

## drop() [2/2]

void mongocxx::v_noabi::collection::drop | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & | write_concern = {},
|  | bsoncxx::v_noabi::document::view_or_value | collection_options = {} )

Drops this collection and all its contained documents from the database.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the drop.
  write_concern | (optional) The write concern to use for this operation. Defaults to the collection wide write concern if none is provided.
  collection_options | (optional) Collection options to use for this operation.

Exceptions

  mongocxx::v_noabi::operation_exception | if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/drop/

Note
  Write concern supported only for MongoDB 3.4+.

## estimated_document_count()

std::int64_t mongocxx::v_noabi::collection::estimated_document_count | ( | v_noabi::options::estimated_document_count const & | options = {} | ) |

Returns an estimate of the number of documents in the collection.

Parameters

  options | Optional arguments, see mongocxx::v_noabi::options::count.

Returns
  The count of the documents that matched the filter.

Exceptions

  mongocxx::v_noabi::query_exception | if the count operation fails.

Note
  This function is implemented in terms of the count server command. See: https://www.mongodb.com/docs/manual/reference/command/count/#behavior for more information.

See also
  - mongocxx::v_noabi::collection::count_documents

## find() [1/2]

v_noabi::cursor mongocxx::v_noabi::collection::find | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::find const & | options = {} )

Finds the documents in this collection which match the provided filter.

Parameters

  filter | Document view representing a document that should match the query.
  options | Optional arguments, see v_noabi::options::find

Returns
  A mongocxx::v_noabi::cursor with the results. If the query fails, the cursor throws mongocxx::v_noabi::query_exception when the returned cursor is iterated.

Exceptions

  mongocxx::v_noabi::logic_error | if the options are invalid, or if the unsupported option modifiers "$query" or "$explain" are used.

See also
  - https://www.mongodb.com/docs/manual/core/read-operations-introduction/

## find() [2/2]

v_noabi::cursor mongocxx::v_noabi::collection::find | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::find const & | options = {} )

Finds the documents in this collection which match the provided filter.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the query.
  filter | Document view representing a document that should match the query.
  options | Optional arguments, see v_noabi::options::find

Returns
  A mongocxx::v_noabi::cursor with the results. If the query fails, the cursor throws mongocxx::v_noabi::query_exception when the returned cursor is iterated.

Exceptions

  mongocxx::v_noabi::logic_error | if the options are invalid, or if the unsupported option modifiers "$query" or "$explain" are used.

See also
  - https://www.mongodb.com/docs/manual/core/read-operations-introduction/

## find_one() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::find const & | options = {} )

Finds a single document in this collection that match the provided filter.

Parameters

  filter | Document view representing a document that should match the query.
  options | Optional arguments, see v_noabi::options::find

Returns
  An optional document that matched the filter.

Exceptions

  mongocxx::v_noabi::query_exception | if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/core/read-operations-introduction/

## find_one() [2/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::find const & | options = {} )

Finds a single document in this collection that match the provided filter.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the query.
  filter | Document view representing a document that should match the query.
  options | Optional arguments, see v_noabi::options::find

Returns
  An optional document that matched the filter.

Exceptions

  mongocxx::v_noabi::query_exception | if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/core/read-operations-introduction/

## find_one_and_delete() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_delete | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::find_one_and_delete const & | options = {} )

Finds a single document matching the filter, deletes it, and returns the original.

Parameters

  filter | Document view representing a document that should be deleted.
  options | Optional arguments, see v_noabi::options::find_one_and_delete

Returns
  The document that was deleted.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_delete() [2/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_delete | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::options::find_one_and_delete const & | options = {} )

Finds a single document matching the filter, deletes it, and returns the original.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  filter | Document view representing a document that should be deleted.
  options | Optional arguments, see v_noabi::options::find_one_and_delete

Returns
  The document that was deleted.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_replace() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_replace | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | replacement,
|  | v_noabi::options::find_one_and_replace const & | options = {} )

Finds a single document matching the filter, replaces it, and returns either the original or the replacement document.

Parameters

  filter | Document view representing a document that should be replaced.
  replacement | Document view representing the replacement for a matching document.
  options | Optional arguments, see v_noabi::options::find_one_and_replace.

Returns
  The original or replaced document.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_replace() [2/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_replace | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | replacement,
|  | v_noabi::options::find_one_and_replace const & | options = {} )

Finds a single document matching the filter, replaces it, and returns either the original or the replacement document.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  filter | Document view representing a document that should be replaced.
  replacement | Document view representing the replacement for a matching document.
  options | Optional arguments, see v_noabi::options::find_one_and_replace.

Returns
  The original or replaced document.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_update() [1/6]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_update | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | update,
|  | v_noabi::options::find_one_and_update const & | options = {} )

Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.

Parameters

  filter | Document view representing a document that should be updated.
  update | Document view representing the update to apply to a matching document.
  options | Optional arguments, see v_noabi::options::find_one_and_update.

Returns
  The original or updated document.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_update() [2/6]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_update | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | std::initializer_list< _empty_doc_tag > | update,
|  | v_noabi::options::find_one_and_update const & | options = {} )

Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.

Parameters

  filter | Document view representing a document that should be updated.
  update | Supports the empty update {}.
  options | Optional arguments, see v_noabi::options::find_one_and_update.

Returns
  The original or updated document.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_update() [3/6]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_update | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::pipeline const & | update,
|  | v_noabi::options::find_one_and_update const & | options = {} )

Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.

Parameters

  filter | Document view representing a document that should be updated.
  update | Pipeline representing the update to apply to a matching document.
  options | Optional arguments, see v_noabi::options::find_one_and_update.

Returns
  The original or updated document.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_update() [4/6]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_update | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | update,
|  | v_noabi::options::find_one_and_update const & | options = {} )

Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  filter | Document view representing a document that should be updated.
  update | Document view representing the update to apply to a matching document.
  options | Optional arguments, see v_noabi::options::find_one_and_update.

Returns
  The original or updated document.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_update() [5/6]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_update | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | std::initializer_list< _empty_doc_tag > | update,
|  | v_noabi::options::find_one_and_update const & | options = {} )

Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  filter | Document view representing a document that should be updated.
  update | Supports the empty update {}.
  options | Optional arguments, see v_noabi::options::find_one_and_update.

Returns
  The original or updated document.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## find_one_and_update() [6/6]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::value > mongocxx::v_noabi::collection::find_one_and_update | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::pipeline const & | update,
|  | v_noabi::options::find_one_and_update const & | options = {} )

Finds a single document matching the filter, updates it, and returns either the original or the newly-updated document.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.
  filter | Document view representing a document that should be updated.
  update | Pipeline representing the update to apply to a matching document.
  options | Optional arguments, see v_noabi::options::find_one_and_update.

Returns
  The original or updated document.

Exceptions

  Throws | mongocxx::v_noabi::logic_error if the collation option is specified and an unacknowledged write concern is used.
  Throws | mongocxx::v_noabi::write_exception if the operation fails.

## indexes()

v_noabi::index_view mongocxx::v_noabi::collection::indexes | ( |  | ) |

Gets an index_view to the collection.

## insert_many() [1/4]

template<typename container_type>

bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > mongocxx::v_noabi::collection::insert_many | ( | container_type const & | container,
|  | v_noabi::options::insert const & | options = {} )

inline

Inserts multiple documents into the collection. If any of the documents are missing identifiers the driver will generate them.

Warning
  This method uses the bulk insert command to execute the insertion as opposed to the legacy OP_INSERT wire protocol message. As a result, using this method to insert many documents on MongoDB < 2.6 will be slow.

Template Parameters

  container_type | The container type. Must meet the requirements for the container concept with a value type of model::write.

Parameters

  container | Container of a documents to insert.
  options | Optional arguments, see v_noabi::options::insert.

Returns
  The optional result of attempting to performing the insert. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | when the operation fails.

## insert_many() [2/4]

template<typename document_view_iterator_type>

bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > mongocxx::v_noabi::collection::insert_many | ( | document_view_iterator_type | begin,
|  | document_view_iterator_type | end,
|  | v_noabi::options::insert const & | options = {} )

inline

Inserts multiple documents into the collection. If any of the documents are missing identifiers the driver will generate them.

Warning
  This method uses the bulk insert command to execute the insertion as opposed to the legacy OP_INSERT wire protocol message. As a result, using this method to insert many documents on MongoDB < 2.6 will be slow.

Template Parameters

  document_view_iterator_type | The iterator type. Must meet the requirements for the input iterator concept with a value type of bsoncxx::v_noabi::document::view.

Parameters

  begin | Iterator pointing to the first document to be inserted.
  end | Iterator pointing to the end of the documents to be inserted.
  options | Optional arguments, see v_noabi::options::insert.

Returns
  The result of attempting to performing the insert.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | if the operation fails.

## insert_many() [3/4]

template<typename container_type>

bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > mongocxx::v_noabi::collection::insert_many | ( | v_noabi::client_session const & | session,
|  | container_type const & | container,
|  | v_noabi::options::insert const & | options = {} )

inline

Inserts multiple documents into the collection. If any of the documents are missing identifiers the driver will generate them.

Template Parameters

  container_type | The container type. Must meet the requirements for the container concept with a value type of model::write.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the inserts.
  container | Container of a documents to insert.
  options | Optional arguments, see v_noabi::options::insert.

Returns
  The optional result of attempting to performing the insert. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | when the operation fails.

## insert_many() [4/4]

template<typename document_view_iterator_type>

bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_many > mongocxx::v_noabi::collection::insert_many | ( | v_noabi::client_session const & | session,
|  | document_view_iterator_type | begin,
|  | document_view_iterator_type | end,
|  | v_noabi::options::insert const & | options = {} )

inline

Inserts multiple documents into the collection. If any of the documents are missing identifiers the driver will generate them.

Template Parameters

  document_view_iterator_type | The iterator type. Must meet the requirements for the input iterator concept with a value type of bsoncxx::v_noabi::document::view.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the inserts.
  begin | Iterator pointing to the first document to be inserted.
  end | Iterator pointing to the end of the documents to be inserted.
  options | Optional arguments, see v_noabi::options::insert.

Returns
  The result of attempting to performing the insert.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | if the operation fails.

## insert_one() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_one > mongocxx::v_noabi::collection::insert_one | ( | bsoncxx::v_noabi::document::view_or_value | document,
|  | v_noabi::options::insert const & | options = {} )

Inserts a single document into the collection. If the document is missing an identifier (`_id` field) one will be generated for it.

Parameters

  document | The document to insert.
  options | Optional arguments, see v_noabi::options::insert.

Returns
  The optional result of attempting to perform the insert. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | if the operation fails.

## insert_one() [2/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::insert_one > mongocxx::v_noabi::collection::insert_one | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | document,
|  | v_noabi::options::insert const & | options = {} )

Inserts a single document into the collection. If the document is missing an identifier (`_id` field) one will be generated for it.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the insert.
  document | The document to insert.
  options | Optional arguments, see v_noabi::options::insert.

Returns
  The optional result of attempting to perform the insert. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::bulk_write_exception | if the operation fails.

## list_indexes() [1/2]

v_noabi::cursor mongocxx::v_noabi::collection::list_indexes | ( |  | ) | const

Returns a list of the indexes currently on this collection.

Returns
  Cursor yielding the index specifications.

Exceptions

  mongocxx::v_noabi::operation_exception | if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/listIndexes/

## list_indexes() [2/2]

v_noabi::cursor mongocxx::v_noabi::collection::list_indexes | ( | v_noabi::client_session const & | session | ) | const

Returns a list of the indexes currently on this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the operation.

Returns
  Cursor yielding the index specifications.

Exceptions

  mongocxx::v_noabi::operation_exception | if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/listIndexes/

## name()

bsoncxx::v_noabi::stdx::string_view mongocxx::v_noabi::collection::name | ( |  | ) | const

Returns the name of this collection.

Returns
  The name of the collection. The return value of this method is invalidated by any subsequent call to collection::rename() on this collection object.

## operator bool()

mongocxx::v_noabi::collection::operator bool | ( |  | ) | const

explicit noexcept

Returns true if the collection is valid, meaning it was not default constructed or moved from.

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

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

inline explicit

Convert to the mongocxx::v1 equivalent.

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

Warning
  Invalidates all associated objects.

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

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

inline explicit

Convert to the mongocxx::v1 equivalent.

## operator=() [1/2]

collection & mongocxx::v_noabi::collection::operator= | ( | collection && | other | ) |

default noexcept

Move assigns a collection.

## operator=() [2/2]

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

Copy assigns a collection.

## read_concern() [1/2]

v_noabi::read_concern mongocxx::v_noabi::collection::read_concern | ( |  | ) | const

Gets the read_concern for the collection.

If a read_concern has not been explicitly set for this collection object, it inherits the read_concern from its parent database or client object.

Returns
  The current read_concern.

## read_concern() [2/2]

void mongocxx::v_noabi::collection::read_concern | ( | v_noabi::read_concern | rc | ) |

Sets the read_concern for this collection. Changes will not have any effect on existing cursors or other read operations which use the previously-set read concern.

Parameters

  rc | The new `read_concern`

See also
  - https://www.mongodb.com/docs/manual/reference/read-concern/

## read_preference() [1/2]

v_noabi::read_preference mongocxx::v_noabi::collection::read_preference | ( |  | ) | const

Gets the read_preference for the collection.

Returns
  The current read_preference.

See also
  - https://www.mongodb.com/docs/manual/core/read-preference/

## read_preference() [2/2]

void mongocxx::v_noabi::collection::read_preference | ( | v_noabi::read_preference | rp | ) |

Sets the read_preference for this collection. Changes will not have any effect on existing cursors or other read operations which use the read preference.

Parameters

  rp | The read_preference to set.

See also
  - https://www.mongodb.com/docs/manual/core/read-preference/

## rename() [1/2]

void mongocxx::v_noabi::collection::rename | ( | bsoncxx::v_noabi::string::view_or_value | new_name,
|  | bool | drop_target_before_rename = false,
|  | bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & | write_concern = {} )

Rename this collection.

Parameters

  new_name | The new name to assign to the collection.
  drop_target_before_rename | Whether to overwrite any existing collections called new_name. The default is false.
  write_concern | (optional) The write concern to use for this operation. Defaults to the collection wide write concern if none is provided.

Exceptions

  mongocxx::v_noabi::operation_exception | if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/renameCollection/

Note
  Write concern supported only for MongoDB 3.4+.

## rename() [2/2]

void mongocxx::v_noabi::collection::rename | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::string::view_or_value | new_name,
|  | bool | drop_target_before_rename = false,
|  | bsoncxx::v_noabi::stdx::optional< v_noabi::write_concern > const & | write_concern = {} )

Rename this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the rename.
  new_name | The new name to assign to the collection.
  drop_target_before_rename | Whether to overwrite any existing collections called new_name. The default is false.
  write_concern | (optional) The write concern to use for this operation. Defaults to the collection wide write concern if none is provided.

Exceptions

  mongocxx::v_noabi::operation_exception | if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/renameCollection/

Note
  Write concern supported only for MongoDB 3.4+.

## replace_one() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::replace_one > mongocxx::v_noabi::collection::replace_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | replacement,
|  | v_noabi::options::replace const & | options = {} )

Replaces a single document matching the provided filter in this collection.

Parameters

  filter | Document representing the match criteria.
  replacement | The replacement document.
  options | Optional arguments, see v_noabi::options::replace.

Returns
  The optional result of attempting to replace a document. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the replacement is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## replace_one() [2/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::replace_one > mongocxx::v_noabi::collection::replace_one | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | replacement,
|  | v_noabi::options::replace const & | options = {} )

Replaces a single document matching the provided filter in this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the replace.
  filter | Document representing the match criteria.
  replacement | The replacement document.
  options | Optional arguments, see v_noabi::options::replace.

Returns
  The optional result of attempting to replace a document. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the replacement is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## search_indexes()

v_noabi::search_index_view mongocxx::v_noabi::collection::search_indexes | ( |  | ) |

Gets a search_index_view to the collection.

## update_many() [1/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_many | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | update,
|  | v_noabi::options::update const & | options = {} )

Updates multiple documents matching the provided filter in this collection.

Parameters

  filter | Document representing the match criteria.
  update | Document representing the update to be applied to matching documents.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update multiple documents. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_many() [2/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_many | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | std::initializer_list< _empty_doc_tag > | update,
|  | v_noabi::options::update const & | options = {} )

Updates multiple documents matching the provided filter in this collection.

Parameters

  filter | Document representing the match criteria.
  update | Supports the empty update {}.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update multiple documents. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_many() [3/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_many | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::pipeline const & | update,
|  | v_noabi::options::update const & | options = {} )

Updates multiple documents matching the provided filter in this collection.

Parameters

  filter | Document representing the match criteria.
  update | Pipeline representing the update to be applied to matching documents.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update multiple documents. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_many() [4/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_many | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | update,
|  | v_noabi::options::update const & | options = {} )

Updates multiple documents matching the provided filter in this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the update.
  filter | Document representing the match criteria.
  update | Document representing the update to be applied to matching documents.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update multiple documents. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_many() [5/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_many | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | std::initializer_list< _empty_doc_tag > | update,
|  | v_noabi::options::update const & | options = {} )

Updates multiple documents matching the provided filter in this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the update.
  filter | Document representing the match criteria.
  update | Supports the empty update {}.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update multiple documents. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_many() [6/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_many | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::pipeline const & | update,
|  | v_noabi::options::update const & | options = {} )

Updates multiple documents matching the provided filter in this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the update.
  filter | Document representing the match criteria.
  update | Pipeline representing the update to be applied to matching documents.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update multiple documents. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_one() [1/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | update,
|  | v_noabi::options::update const & | options = {} )

Updates a single document matching the provided filter in this collection.

Parameters

  filter | Document representing the match criteria.
  update | Document representing the update to be applied to a matching document.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update a document. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_one() [2/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | std::initializer_list< _empty_doc_tag > | update,
|  | v_noabi::options::update const & | options = {} )

Updates a single document matching the provided filter in this collection.

Parameters

  filter | Document representing the match criteria.
  update | Supports the empty update {}.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update a document. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_one() [3/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::pipeline const & | update,
|  | v_noabi::options::update const & | options = {} )

Updates a single document matching the provided filter in this collection.

Parameters

  filter | Document representing the match criteria.
  update | Pipeline representing the update to be applied to a matching document.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update a document. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_one() [4/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_one | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | update,
|  | v_noabi::options::update const & | options = {} )

Updates a single document matching the provided filter in this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the update.
  filter | Document representing the match criteria.
  update | Document representing the update to be applied to a matching document.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update a document. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_one() [5/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_one | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | std::initializer_list< _empty_doc_tag > | update,
|  | v_noabi::options::update const & | options = {} )

Updates a single document matching the provided filter in this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the update.
  filter | Document representing the match criteria.
  update | Supports the empty update {}.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update a document. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## update_one() [6/6]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::update > mongocxx::v_noabi::collection::update_one | ( | v_noabi::client_session const & | session,
|  | bsoncxx::v_noabi::document::view_or_value | filter,
|  | v_noabi::pipeline const & | update,
|  | v_noabi::options::update const & | options = {} )

Updates a single document matching the provided filter in this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the update.
  filter | Document representing the match criteria.
  update | Pipeline representing the update to be applied to a matching document.
  options | Optional arguments, see v_noabi::options::update.

Returns
  The optional result of attempting to update a document. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

  mongocxx::v_noabi::logic_error | if the update is invalid, or mongocxx::v_noabi::bulk_write_exception if the operation fails.

See also
  - https://www.mongodb.com/docs/manual/reference/command/update/

## watch() [1/4]

v_noabi::change_stream mongocxx::v_noabi::collection::watch | ( | v_noabi::client_session const & | session,
|  | v_noabi::options::change_stream const & | options = {} )

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the watch operation.
  options | The options to use when creating the change stream.

Returns
  A change stream on this collection.

See also
  - https://www.mongodb.com/docs/manual/changeStreams/

## watch() [2/4]

v_noabi::change_stream mongocxx::v_noabi::collection::watch | ( | v_noabi::client_session const & | session,
|  | v_noabi::pipeline const & | pipe,
|  | v_noabi::options::change_stream const & | options = {} )

Gets a change stream on this collection.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the watch operation.
  pipe | The aggregation pipeline to be used on the change notifications.
  options | The options to use when creating the change stream.

Returns
  A change stream on this collection.

See also
  - https://www.mongodb.com/docs/manual/changeStreams/

## watch() [3/4]

v_noabi::change_stream mongocxx::v_noabi::collection::watch | ( | v_noabi::options::change_stream const & | options = {} | ) |

Gets a change stream on this collection with an empty pipeline. Change streams are only supported with a "majority" read concern or no read concern.

Parameters

  options | The options to use when creating the change stream.

Returns
  A change stream on this collection.

See also
  - https://www.mongodb.com/docs/manual/changeStreams/

## watch() [4/4]

v_noabi::change_stream mongocxx::v_noabi::collection::watch | ( | v_noabi::pipeline const & | pipe,
|  | v_noabi::options::change_stream const & | options = {} )

Gets a change stream on this collection. Change streams are only supported with a "majority" read concern or no read concern.

Parameters

  pipe | The aggregation pipeline to be used on the change notifications. Only a subset of pipeline operations are supported for change streams. For more information see the change streams documentation.
  options | The options to use when creating the change stream.

Returns
  A change stream on this collection.

See also
  - https://www.mongodb.com/docs/manual/changeStreams/

## write() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > mongocxx::v_noabi::collection::write | ( | v_noabi::client_session const & | session,
|  | v_noabi::model::write const & | write,
|  | v_noabi::options::bulk_write const & | options = {} )

inline

Sends a write to the server as a bulk write operation.

Parameters

  session | The mongocxx::v_noabi::client_session with which to perform the bulk operation.
  write | A model::write.
  options | Optional arguments, see v_noabi::options::bulk_write.

Returns
  The optional result of the bulk operation execution. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

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

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

## write() [2/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::result::bulk_write > mongocxx::v_noabi::collection::write | ( | v_noabi::model::write const & | write,
|  | v_noabi::options::bulk_write const & | options = {} )

inline

Sends a write to the server as a bulk write operation.

Parameters

  write | A model::write.
  options | Optional arguments, see v_noabi::options::bulk_write.

Returns
  The optional result of the bulk operation execution. If the write concern is unacknowledged, the optional will be disengaged.

Exceptions

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

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

## write_concern() [1/2]

v_noabi::write_concern mongocxx::v_noabi::collection::write_concern | ( |  | ) | const

Gets the write_concern for the collection.

Returns
  The current write_concern.

## write_concern() [2/2]

void mongocxx::v_noabi::collection::write_concern | ( | v_noabi::write_concern | wc | ) |

Sets the write_concern for this collection. Changes will not have any effect on existing write operations.

Parameters

  wc | The new write_concern to use.

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

- mongocxx/v_noabi/mongocxx/collection.hpp