Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-797

Updating entire document without operators such as set fails at execution with Cannot do an empty bulk write

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 0.2.0
    • Fix Version/s: None
    • Component/s: Implementation
    • Labels:
      None
    • Sprint:
      Platforms E (01/08/16)

      Description

      As per mongodb documentation, updating entire document is possible as:

      update.js

      db.people.update(
         { name: "Andy" },
         {
            name: "Andy",
            rating: 1,
            score: 1
         },
         { upsert: true }
      )
      

      One need provide update operators such as $set only when updating sub-document. The same should be achieveable with the C++11 driver as:

      update.cxx

          {
              // @begin: cpp-update-top-level-fields
              bsoncxx::builder::stream::document filter_builder, update_builder;
              filter_builder << "name"
                             << "Juni";
              update_builder << "cuisine"
                             << "American (New)";
       
              db["restaurants"].update_one(filter_builder.view(), update_builder.view());
              // @end: cpp-update-top-level-fields
          }
      

      However, executing the above code leads to
      terminate called after throwing an instance of

      stderr

      'mongocxx::v0::bulk_write_exception'
        what():  Cannot do an empty bulk write: mongoc command_invalid_arg error
      

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: