Settings the fullResponse option to true in an insertMany call causes the insertedCount property to be '0'

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor - P4
    • 4.1.1
    • Affects Version/s: None
    • Component/s: None
    • None
    • Not Needed
    • None
    • None
    • None
    • None
    • None
    • None

      What problem are you facing?

      If the fullResponse option is set to true for an insertMany call, the 'insertedCount' field in the response is always equal to zero.  If not included, or set to false, then that field contains the correct number of inserted documents.

      What driver and relevant dependency versions are you using?

      mongodb@4.0.1

      Steps to reproduce?

      const documents = [ /* 4 docs to insert */ ];
      const db = mongoClient.db(databaseName);
      const collection = db.collection(collectionName);
      
      const result = await collection.insertMany(documents, {fullResponse: true});
      // results.insertedCount = 0
      // results.insertedIds has 4 document IDs

      If fullResponse is not included in the options, or is set to false, then insertedCount is correctly be set to 4.

       

      As a side-note, setting fullResponse to true doesn't actually include any additional information in the response, which might be a bigger issue.

       

              Assignee:
              Daria Pardue
              Reporter:
              Jerren Saunders
              Neal Beeken
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: