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

Clean up `Collection.prototype.find` parameter handling

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      The `find` method on `Collection.prototype` has gone through many painful iterations which has left it in a troublesome state in terms of parameter management. It would seem that the signature for this function should be something like `function(query, fields, options, callback)`, however it has to do a number of checks to verify that previously supported forms aren't being used. Most importantly, it lacks almost any documentation because there was an emphasis on using chaining to support all the additional features of find.

      I think we should break this in 3.x, and only support `find(query, options, callback)`. `fields` actually just turns out to be an alias for `project`, and we already have a chainable helper for this. This also allows us to remove a ton of type checking code in the method itself.

      *NOTE:* This will almost certainly cause some users serious pain, but if we properly document the change and how to migrate away from it I am confident the end result works better for all parties.

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            matt.broadstone@mongodb.com Matt Broadstone
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: