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

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

## Description

A MongoDB update operation that modifies a single document.

## Public Member Functions

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

## Constructor & Destructor Documentation

## update_one() [1/4]

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

Construct with the mongocxx::v1 equivalent.

## update_one() [2/4]

mongocxx::v_noabi::model::update_one::update_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | bsoncxx::v_noabi::document::view_or_value | update )

inline

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

Parameters

  filter | Document representing the criteria for applying the update.
  update | Document representing the modifications to be applied to the matching document.

## update_one() [3/4]

mongocxx::v_noabi::model::update_one::update_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | pipeline const & | update )

inline

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

Parameters

  filter | Document representing the criteria for applying the update.
  update | Pipeline representing the modifications to be applied to the matching document.

## update_one() [4/4]

mongocxx::v_noabi::model::update_one::update_one | ( | bsoncxx::v_noabi::document::view_or_value | filter,
|  | std::initializer_list< _empty_doc_tag > | update )

inline

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

Parameters

  filter | Document representing the criteria for applying the update.
  update | Supports the empty update {}.

## Member Function Documentation

## array_filters() [1/2]

bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::array::view_or_value > const & mongocxx::v_noabi::model::update_one::array_filters | ( |  | ) | const

inline

Get array filters for this operation.

Returns
  The current array filters.

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

## array_filters() [2/2]

update_one & mongocxx::v_noabi::model::update_one::array_filters | ( | bsoncxx::v_noabi::array::view_or_value | array_filters | ) |

inline

Set array filters for this update operation.

Parameters

  array_filters | Array representing filters determining which array elements to modify.

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

## collation() [1/2]

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

inline

Gets the collation option for this update operation.

Returns
  The optional value of the collation option.

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

## collation() [2/2]

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

inline

Sets the collation for this update 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::update_one::filter | ( |  | ) | const

inline

Gets the filter.

Returns
  The filter to be used for the update operation.

## hint() [1/2]

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

inline

Gets the current hint.

Returns
  The current hint, if one is set.

## hint() [2/2]

update_one & mongocxx::v_noabi::model::update_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::update_one()

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

inline explicit

Convert to the mongocxx::v1 equivalent.

## sort() [1/2]

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

inline

Get the current value of the sort option.

## sort() [2/2]

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

inline

Set the sort option.

## update()

bsoncxx::v_noabi::document::view_or_value const & mongocxx::v_noabi::model::update_one::update | ( |  | ) | const

inline

Gets the update document.

Returns
  The modifications to be applied as part of the update.

## upsert() [1/2]

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

inline

Gets the current value of the upsert option.

Returns
  The optional value of the upsert option.

## upsert() [2/2]

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

inline

Sets the upsert option.

When upsert is `false`, if no document matches the filter, update does nothing. However, by specifying upsert as `true`, this operation either updates a matching document or inserts a new document using the update specification if no matching document exists. 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/update_one.hpp