Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-3093

Include inserted _Ids in insert_one() and insert() results

    XMLWordPrintableJSON

Details

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Minor - P4 Minor - P4
    • None
    • None
    • libmongoc

    Description

      As per http://mongoc.org/libmongoc/current/mongoc_collection_insert_one.html and http://mongoc.org/libmongoc/current/mongoc_collection_insert.html, there is currently no option to return the generated _id(s):

      If no _id element is found in document, then a bson_oid_t will be generated locally and added to the document. If you must know the inserted document’s _id, generate it in your code and include it in the document. The _id you generate can be a bson_oid_t or any other non-array BSON type.

      Although providing the inserted id(s) is not required according to the MongoDB CRUD spec, it would be useful to expose this in the C driver to assist downstream drivers such as mongolite that use libmongoc.

      Attachments

        Activity

          People

            Unassigned Unassigned
            stephen.steneker@mongodb.com Stennie Steneker (Inactive)
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated: