-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
None
-
Fully Compatible
Implement these new functions:
bool mongoc_bulk_operation_remove_with_opts (mongoc_bulk_operation_t *bulk, const bson_t *selector, const bson_t *opts, bson_error_t *error); /* OUT */ bool mongoc_bulk_operation_remove_one_with_opts (mongoc_bulk_operation_t *bulk, const bson_t *selector, const bson_t *opts, bson_error_t *error); /* OUT */ bool 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 */ bool mongoc_bulk_operation_update_with_opts (mongoc_bulk_operation_t *bulk, const bson_t *selector, const bson_t *document, const bson_t *opts, bson_error_t *error); /* OUT */ bool mongoc_bulk_operation_update_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 */
"opts" can be NULL. I think each function appends "opts" to the operation without any validation. Example for write commands:
opts = BCON_NEW ("upsert", BCON_BOOL (true)); query = BCON_NEW ("_id", BCON_INT32 (4)); doc = BCON_NEW ("$inc", "{", "j", BCON_INT32 (1), "}"); mongoc_bulk_operation_update_with_opts (bulk, query, doc, opts);
This produces:
{update: "collection", updates: [{ q: {_id: 4}, u: {$inc: {j: 1}}, upsert: true }]}
Another example:
/* "One" normally sorts before "one"; make "one" come first */ opts = BCON_NEW ("collation", "{", "locale", BCON_UTF8 ("en_US"), "caseFirst", BCON_UTF8 ("lower"), "}"); /* set x=1 on the document with _id "One", which now sorts after "one" */ update = BCON_NEW ("$set", "{", "x", BCON_INT64 (1), "}"); selector = BCON_NEW ("_id", "{", "$gt", BCON_UTF8 ("one"), "}"); mongoc_bulk_operation_update_one_with_opts (bulk, selector, update, opts);
Produces:
{update: "collection", updates: [{ q: {_id: "one"}, u: {$set: {x: 1}}, collation: {locale: "en_US", caseFirst: "lower"} }]}
Once this is complete, re-enable the bulk upsert and bulk collation examples by reverting this commit:
https://github.com/mongodb/mongo-c-driver/commit/a497587867fe28dac954d0244ca6fb4bfc5e4a38
(Yes, revert the revert.)
- is depended on by
-
PHPC-734 Support providing collation per operation
- Closed
-
PHPC-796 Use flexible opts for BulkWrite update and delete
- Closed
-
CDRIVER-1573 Replace bulk_operation_update_with_opts()/bulk_operation_remove_with_opts() with bulk_operation_update_many_with_opts()/bulk_operation_remove_many_with_opts()
- Closed
- is documented by
-
CDRIVER-1536 Document new bulk_operation methods
- Closed