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

Remove `batchSize` as a findOne option and don't set batchSize on the cursor

    • Type: Icon: Improvement Improvement
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Use Case

      See https://mongodb.slack.com/archives/C72LB5RPV/p1729101189007139.

      Shane pointed out recently that the logic for findOne sets a batch size of 1 that isn't needed:

      const cursor = this.find(filter, options).limit(-1).batchSize(1);
          const res = await cursor.next();
          await cursor.close();
          return res;
      

      This has no impact on the command built - because a `limit = -1` sets `singleBatch` to true on the find command with a `limit=1`. Other drivers don't set a batch size in this scenario, we could remove it for clarify and consistency with other drivers.

      While we're here, we should omit `batchSize` as a FindOption, because we expect a single batch with only one document at most.

      User Experience

      n/a

      Dependencies

      n/a

      Risks/Unknowns

      n/a

      Acceptance Criteria

      Implementation Requirements

      Omit batchSize as an option to findOne.
      Don't set batchSize on the cursor before executing the find.

      Testing Requirements

      • unit test, spec test sync, etc

      Documentation Requirements

      • DOCSP ticket, API docs, etc

      Follow Up Requirements

      • additional tickets to file, required releases, etc
      • if node behavior differs/will differ from other drivers, confirm with dbx devs what standard to aim for and what plan, if any, exists to reconcile the diverging behavior moving forward

            Assignee:
            Unassigned Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: