Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3511

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

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

      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@mongodb.com Daria Pardue
            Reporter:
            jerren_s@hotmail.com Jerren Saunders
            Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: