I am using MongoDB with the c-client, mongoc 1.8.1.
I am performing a bulk update, with 6 mongoc_bulk_operation_update_one() operations. However, for 3 of the updates the selection document does not match anything in the database (say query1,query2,query3).
...
mongoc_bulk_operation_t* pBulk = mongoc_collection_create_bulk_operation(coll_,false,NULL); //unorderd
mongoc_bulk_operation_update_one(pBulk,&query1,&document,false);
mongoc_bulk_operation_update_one(pBulk,&query2,&document,false);
mongoc_bulk_operation_update_one(pBulk,&query3,&document,false);
mongoc_bulk_operation_update_one(pBulk,&query4,&document,false);
mongoc_bulk_operation_update_one(pBulk,&query5,&document,false);
mongoc_bulk_operation_update_one(pBulk,&query6,&document,false);
bson_t reply;
bson_error_t error;
uint32_t ret = mongoc_bulk_operation_execute(pBulk,&reply,&error);
if (ret) {
str = bson_as_canonical_extended_json (&reply, NULL);
printf ("%s\n", str);
bson_free (str);
}
The reply document counts the number matched and modified correctly (3):
reply={ "nInserted" : { "$numberInt" : "0" }, "nMatched" : { "$numberInt" : "3" }, "nModified" : { "$numberInt" : "3" }, "nRemoved" : { "$numberInt" : "0" }, "nUpserted" : { "$numberInt" : "0" }, "writeErrors" : [ ] };
but does not give a clue on which updates did NOT match.
Is there a way to perform this operation in a way that will give me the indices of the updates that did not match?