mongoc_bulk_operation_replace_one_with_opts (mongoc_bulk_operation_t *bulk,
                                             const bson_t *selector,
                                             const bson_t *document,
                                             const bson_t *opts,
                                             bson_error_t *error); /* OUT */

Replace a single document as part of a bulk operation. This only queues the operation. To execute it, call mongoc_bulk_operation_execute().


opts may be NULL or a BSON document with additional command options:

  • validate: Construct a bitwise-or of all desired bson_validate_flags_t. Set to false to skip client-side validation of the provided BSON documents.

  • collation: Configure textual comparisons. See Setting Collation Order, and the MongoDB Manual entry on Collation. Collation requires MongoDB 3.2 or later, otherwise an error is returned.

  • hint: A document or string that specifies the index to use to support the query predicate.

  • upsert: If true, insert a document if none match selector.


document may not contain fields with keys containing . or $.


Operation errors are propagated via mongoc_bulk_operation_execute(), while argument validation errors are reported by the error argument.


Returns true on success, and false if passed invalid arguments.