Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-4584

Add length option to Cursor.to_list for motor compat

    • Type: Icon: New Feature New Feature
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.9
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers
    • 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?

      Add "length" option to Cursor.to_list for motor compat. See https://motor.readthedocs.io/en/latest/api-asyncio/cursors.html#motor.motor_asyncio.AsyncIOMotorCursor.to_list

      Motor's length option is required while I believe pymongo's should be optional, defaulting to None. This yields a more natural api since passing length=None is awkward:

      # returns all docs
      await cursor.to_list()
      # returns all docs
      await cursor.to_list(length=None)
      # returns at most 5 docs
      await cursor.to_list(length=5)
      

      .

            Assignee:
            steve.silvester@mongodb.com Steve Silvester
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: