Loading...
Searching...
No Matches
mongocxx::model::replace_one Class Reference

`#include <mongocxx/v_noabi/mongocxx/model/replace_one.hpp>`

## Description

A MongoDB update operation that replaces a single document.

## Public Member Functions

| replace_one (bsoncxx::v_noabi::document::view_or_value filter, bsoncxx::v_noabi::document::view_or_value replacement)
| Constructs an update operation that will replace a single document matching the filter.
| replace_one (v1::bulk_write::replace_one op)
| Construct with the mongocxx::v1 equivalent.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & | collation () const
| Gets the collation option for this replacement operation.
replace_one & | collation (bsoncxx::v_noabi::document::view_or_value collation)
| Sets the collation for this replacement operation.
bsoncxx::v_noabi::document::view_or_value const & | filter () const
| Gets the filter for replacement.
bsoncxx::v_noabi::stdx::optional< v_noabi::hint > const & | hint () const
| Gets the current hint.
replace_one & | hint (v_noabi::hint index_hint)
| Sets the index to use for this operation.
| operator v1::bulk_write::replace_one () const
| Convert to the mongocxx::v1 equivalent.
bsoncxx::v_noabi::document::view_or_value const & | replacement () const
| Gets the replacement document.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & | sort () const
| Get the current value of the sort option.
replace_one & | sort (bsoncxx::v_noabi::document::view_or_value sort)
| Set the sort option.
bsoncxx::v_noabi::stdx::optional< bool > const & | upsert () const
| Gets the current value of the upsert option.
replace_one & | upsert (bool upsert)
| Sets the upsert option.

## Constructor & Destructor Documentation

## replace_one() [1/2]

mongocxx::v_noabi::model::replace_one::replace_one | ( | v1::bulk_write::replace_one | op | ) |

Construct with the mongocxx::v1 equivalent.

## replace_one() [2/2]

mongocxx::v_noabi::model::replace_one::replace_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | replacement )

inline

Constructs an update operation that will replace a single document matching the filter.

Parameters

  filter | Document representing the criteria for replacement.
  replacement | Document that will serve as the replacement.

## Member Function Documentation

## collation() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & mongocxx::v_noabi::model::replace_one::collation | ( |  | ) | const

inline

Gets the collation option for this replacement operation.

Returns
  The optional value of the collation option.

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

## collation() [2/2]

replace_one & mongocxx::v_noabi::model::replace_one::collation | ( | bsoncxx::v_noabi::document::view_or_value | collation | ) |

inline

Sets the collation for this replacement operation.

Parameters

  collation | The new collation.

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

## filter()

bsoncxx::v_noabi::document::view_or_value const & mongocxx::v_noabi::model::replace_one::filter | ( |  | ) | const

inline

Gets the filter for replacement.

Returns
  The filter to be used for the replacement operation.

## hint() [1/2]

bsoncxx::v_noabi::stdx::optional< v_noabi::hint > const & mongocxx::v_noabi::model::replace_one::hint | ( |  | ) | const

inline

Gets the current hint.

Returns
  The current hint, if one is set.

## hint() [2/2]

replace_one & mongocxx::v_noabi::model::replace_one::hint | ( | v_noabi::hint | index_hint | ) |

inline

Sets the index to use for this operation.

Note
  if the server already has a cached shape for this query, it may ignore a hint.

Parameters

  index_hint | Object representing the index to use.

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

## operator v1::bulk_write::replace_one()

mongocxx::v_noabi::model::replace_one::operator v1::bulk_write::replace_one | ( |  | ) | const

inline explicit

Convert to the mongocxx::v1 equivalent.

## replacement()

bsoncxx::v_noabi::document::view_or_value const & mongocxx::v_noabi::model::replace_one::replacement | ( |  | ) | const

inline

Gets the replacement document.

Returns
  The document that will replace the original selected document.

## sort() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view_or_value > const & mongocxx::v_noabi::model::replace_one::sort | ( |  | ) | const

inline

Get the current value of the sort option.

## sort() [2/2]

replace_one & mongocxx::v_noabi::model::replace_one::sort | ( | bsoncxx::v_noabi::document::view_or_value | sort | ) |

inline

Set the sort option.

## upsert() [1/2]

bsoncxx::v_noabi::stdx::optional< bool > const & mongocxx::v_noabi::model::replace_one::upsert | ( |  | ) | const

inline

Gets the current value of the upsert option.

Returns
  The optional value of the upsert option.

## upsert() [2/2]

replace_one & mongocxx::v_noabi::model::replace_one::upsert | ( | bool | upsert | ) |

inline

Sets the upsert option.

When upsert is `true`, this operation will insert the replacement document as a new document if no existing documents match the filter. When upsert is `false`, the replacement operation does nothing if there are no matching documents. By default, upsert is `false`.

Parameters

  upsert | If set to `true`, creates a new document when no document matches the query criteria. The server side default is `false`, which does not insert a new document if a match is not found.

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

- mongocxx/v_noabi/mongocxx/model/replace_one.hpp