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

Find related methods documentation is not accurate

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.2.33, 2.2.34
    • Component/s: None
    • Labels:

      Hello.

      This issue affects the documentation of versions 2.3.X
      The documentation of the find methods on the class cursos is not accurate and this creates confusion, especially when things that should not work according to documentation works in practice.

      Let me explain this with an example. According to documentation find only accepts a single parameter, the query, but looking at the code we can extract the following assertions

      • It also accepts a second parameter that can be either an object or an array
      • If the second parameter is an object and it has a fields property that property will be used as projection
      • If the second parameter is an object, and any of its properties is a know property (fingers crossed), then it will be used as projection. This is specially risky because some known fields are as generic as max and min.
      • If the second parameter is an array, a projection object will be created with all the properties as keys of the new object

      This situation can create very confusing scenarios. For example, I saw several uses of the mongo driver providing a second argument as projection. Looking at the documentation I thought this code was wrong, but it was working, so I had to debug the mongo driver to see all the scenarios described above.
      The questions are:

      • will that scenarios be documented some day ?
      • Is it a bad Idea to make use of the described features ?
      • Will those hidden features be removed on a near future ?

      Thanks in advance

            Assignee:
            Unassigned Unassigned
            Reporter:
            danielo@caseonit.com Daniel Rodríguez
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: