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

collection::find_one_and_* should return result::find_one_and_* objects

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • None
    • API

    Description

      The return type of the collection::find_one_and_*() methods is currently stdx::optional<bsoncxx::document::value>. These methods return a disengaged optional if the "value" field from the findAndModify command response is null; otherwise, they return the document that was returned in "value".

      Instead, collection::find_one_and_*() should result objects (i.e. result::find_one_and_*), like the rest of the write methods do. This would be preferable for the following reasons:

      • Consistency with the rest of the write methods.
      • In the case of an upsert operation, the _id of the inserted document could be exposed. Currently, if a k_before find_one_and_update with an upsert is issued and the operation results in an insert, the user does not have access to the _id of the inserted document.
      • The result object could include a manufactured result::bulk_write object. This would allow clients to re-use code to process the result of these operations that was already written to process the result of other write operations.
      • If the server adds any new useful information to the findAndModify command response in the future, this information could be added to the return value without changing the return type of these API methods.

      Attachments

        Activity

          People

            Unassigned Unassigned
            rassi J Rassi
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: